/* ############################################# # Program Menu "Switch (Identifier)" PART I ############################################# Ket : mn = Menu 1. Bakso = Harga Rp.7500-, 2. Mie Ayam = Harga Rp.8000-, 3. Sate Ayam = Harga Rp.9000-, 4. Sate Kambing = Harga Rp.10.000-, 5. Nasi Goreng = Harga Rp.6000-, (Selai Dari di atas Menu Tidak ada) */ #include<stdio.h> #include<conio.h> void main() { int mn; printf("=======================\n"); printf("DAFTAR MENU MAKAN\n"); printf("=======================\n"); printf("1. Bakso\n"); printf("2. Mie Ayam\n"); printf("3. Sate Ayam\n"); printf("4. Sate Kambing\n"); printf("5. Nasi Goreng\n"); printf("\n"); printf("Pilih Menu = ");scanf("%d",&mn); switch(mn) { case 1: printf("Harga = Rp.7500");break; case 2: printf("Harga = Rp.8000");break; case 3: printf("Harga = Rp.9000");break; case 4: printf("Harga = Rp.10.000");break; case 5: printf("Harga = Rp.6000");break; default: printf("Menu Tidak Ada");break; } getch(); }
PART II
/* ############################################# # Program Menu "Switch (Identifier)" PART II ############################################# Ket : mn = Menu np = Nama Pembeli 1. Bakso = Harga Rp.7500-, 2. Mie Ayam = Harga Rp.8000-, 3. Sate Ayam = Harga Rp.9000-, 4. Sate Kambing = Harga Rp.10.000-, 5. Nasi Goreng = Harga Rp.6000-, Output : Harga Makanan - Nama Pembeli - Nama Makanan */ #include<stdio.h> #include<conio.h> void main() { int mn; char np[50]; printf("=======================\n"); printf("DAFTAR MENU MAKAN\n"); printf("=======================\n"); printf("1. Bakso\n"); printf("2. Mie Ayam\n"); printf("3. Sate Ayam\n"); printf("4. Sate Kambing\n"); printf("5. Nasi Goreng\n"); printf("\n"); printf("Nama Pembeli = ");scanf("%s",&np); printf("Pilih Menu = ");scanf("%d",&mn); switch(mn) { case 1: printf("\n=======================\n");printf("Harga = Rp.7500");printf("\n=======================\n");break; case 2: printf("\n=======================\n");printf("Harga = Rp.8000");printf("\n=======================\n");break; case 3: printf("\n=======================\n");printf("Harga = Rp.9000");printf("\n=======================\n");break; case 4: printf("\n=======================\n");printf("Harga = Rp.10.000");printf("\n=======================\n");break; case 5: printf("\n=======================\n");printf("Harga = Rp.6000");printf("\n=======================\n");break; default: printf("\n=========================\n");printf("Menu Tidak Ada");printf("\n=========================\n");break; } if (mn==1) { printf("\nHay %s",np);printf(" Kamu Membeli Bakso"); } else if (mn==2) { printf("\nHay %s",np);printf(" Kamu Membeli Mie Ayam"); } else if (mn==3) { printf("\nHay %s",np);printf(" Kamu Membeli Sate Ayam"); } else if (mn==4) { printf("\nHay %s",np);printf(" Kamu Membeli Sate Kambing"); } else if (mn==5) { printf("\nHay %s",np);printf(" Kamu Membeli Nasi Goreng"); } getch(); }
PART III
/* ############################################## # Program Menu "Switch (Identifier)" PART III ############################################## Ket : menu1 = Pemilihan Menu Makanan hg1 = Harga Pembelian Makanan menu2 = Pemiiihan Menu Minuman hg2 = Harga Pembelian Minuman jmkn = Jumlah Makanan tp = Total Pembayaran jmnm = Jumlah Minuman mkn = Nama Makanan mnm = Nama Minuman Total : (Jumlah Makanan X Harga Makanan) + (Jumlah Minuman X Harga Minuman) Output : Nama Makanan Harga Makanan Jumlah makanan Nama Minuman Harga Minuman Jumlah Minuman Total Pembayaran */ #include<stdio.h> #include<conio.h> #include<string.h> void main() { int menu1,menu2,jmkn,jmnm; char mkn[10],mnm[10]; float hg1,hg2,tp; printf("=================================\n"); printf("Menu Makanan Resto\n"); printf("=================================\n"); printf("1. Tempoyak\n"); printf("2. Nasi Kosong\n"); printf("3. Sayur Asam\n"); printf("4. Tahu/Tempe Goreng\n"); printf("\n"); printf("=================================\n"); printf("Minuman \n"); printf("=================================\n"); printf("1. Teh Botol\n"); printf("2. Teh Hangat\n"); printf("3. Es kosong\n"); printf("4. Kopi\n"); printf("\n"); printf("Pilih Makan = ");scanf("%i",&menu1); printf("Jumlah Makan = ");scanf("%d",&jmkn); printf("Pilih Minum = ");scanf("%i",&menu2); printf("Jumlah Minum = ");scanf("%d",&jmnm); switch(menu1) { case 1: strcpy(mkn,"Tempoyak"); hg1=5500; break; case 2: strcpy(mkn,"Nasi Goreng"); hg1=6000; break; case 3: strcpy(mkn,"Sayur Asam"); hg1=8000; break; case 4: strcpy(mkn,"Tahu/Tempe Goreng"); hg1=5000; break; } switch(menu2) { case 1: strcpy(mnm,"Teh Botol"); hg2=2500; break; case 2: strcpy(mnm,"Teh Hangat"); hg2=1000; break; case 3: strcpy(mnm,"Es kosong"); hg2=1000; break; case 4: strcpy(mnm,"Kopi"); hg2=2000; break; } tp=jmkn*hg1+jmnm*hg2; printf("\nMakanan Yang anda pilih %s",mkn);printf(" Harga Rp.%5.2f",hg1);printf(" Jumlah %i",jmkn); printf("\nMinuman Yang anda Pilih %s",mnm);printf(" Harga Rp.%5.2f",hg2);printf(" Jumlah %i",jmnm); printf("\n=============================\n"); printf("Total Pembayaran = Rp.%5.2f",tp); printf("\n=============================\n"); getch(); }