Posted by : About Iqbal Kamis, 05 Juni 2014

Hai sobat Blogger, kali ini saya mau membagikan sedikit ilmu yang saya dapat di kampus. Yaitu pembuatan menu menggunakan switch-case dan nested if (if bersarang) dengan bahasa C pada VI editor linux. Nah, berikut penjelasannya :

Listing Program

#include
int main()
{
int uts, uas, pilih, total;
float total1;

printf("==========Menu Pilihan===========");
printf("\n");
printf("1. Perhitungan Nilai\n");
printf("2. Keterangan Kelulusan\n");
printf("3. Keterangan Bobot Nilai\n");
printf("Masukkan Pilihan Anda :\n");
scanf("%d", &pilih);
switch(pilih)
{

case 1 :
printf ("======Perhitungan Nilai======\n");
printf("Masukkan Nilai UTS : "); scanf("%d", &uts);
printf("Masukkan Nilai UAS : "); scanf("%d", &uas);
total1 = (uts + uas)/2;
printf("\n");
printf("Total Nilai Anda : %f \n", total1);
break;

case 2 :
printf("======Keterangan Kelulusan======\n");
printf("Masukkan Total Nilai Anda : "); scanf("%d", &total);
if(total >= 65)
printf("Selamat, Anda Lulus!\n");
else if(total <= 65)
printf("Maaf, Anda Gagal\n");
break;

case 3 :
printf("======Keterangan Bobot Nilai ======\n");
printf("Masukkan Total Nilai Anda : "); scanf("%d", &total);
if(total >= 90 && total <= 100)
{
printf("Bobot Nilai Anda A\n");
}
else if(total >= 75 && total <= 89)
{
printf("Bobot Nilai Anda B\n");
}
else if(total >= 60 && total <= 74)
{
printf("Bobot Nilai Anda C\n");
}
else if(total >= 50 && total <= 59)
{
printf("Bobot Nilai Anda D\n");
}
else if(total >= 0 && total <= 50)
{
printf("Bobot Nilai Anda E\n");
}
break;
}

return 0;
}

Output Program


Logika Program

(Maaf menyusul)



Leave a Reply

Subscribe to Posts | Subscribe to Comments

About Author

Foto saya
IT Student | EDM Enthusiast | Likes Interior Design and Graphic Design | I Also Writing Articles of Games at http://cyberlineteam.com/category/it/game/ | Personal Website : miiqbalrama.hol.es

PageViews

- Copyright © BeOneOfHeroes -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -