Array 1 Dimensi RISMA PARAMESTI 22082010014
package array;
import java.util.Scanner;
public class Array {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String menu[] = new String[8];
int harga[] = new int [8];
int porsi [] = new int [10];
int indeks=0;//index array
int jumlah;
int pilih;
int total=0;
System.out.println("====================================================");
System.out.println(" WARUNG MAKAN SEDERHANA ");
System.out.println(" UPN 'Veteran' Jawa Timur ");
System.out.println("====================================================");
do{
System.out.println("DAFTAR MENU");
System.out.println("1. Nasi Goreng Rp15.000");
System.out.println("2. Mie Goreng Rp13.000");
System.out.println("3. Mie Ayam Rp10.000");
System.out.println("4. Ayam Geprek Rp13.000");
System.out.println("5. Air Mineral Rp3.000");
System.out.println("6. Es Teh Rp4.000");
System.out.println("7. Es Jeruk Rp5.000");
System.out.println("8. Selesai");
System.out.print("Pilih = ");
pilih = sc.nextInt();
switch (pilih){
case 1:
menu[indeks]="Nasi Goreng";
System.out.print("Jumlah = ");
jumlah=sc.nextInt();
porsi[indeks]=jumlah;
harga[indeks]=15000;
total=total+(15000*jumlah);
break;
case 2:
menu[indeks]="Mie Goreng";
System.out.print("Jumlah = ");
jumlah=sc.nextInt();
porsi[indeks]=jumlah;
harga[indeks]=13000;
total=total+(13000*jumlah);
break;
case 3:
menu[indeks]="Mie Ayam";
System.out.print("Jumlah = ");
jumlah=sc.nextInt();
porsi[indeks]=jumlah;
harga[indeks]=10000;
total=total+(10000*jumlah);
break;
case 4:
menu[indeks]="Ayam Geprek";
System.out.print("Jumlah = ");
jumlah=sc.nextInt();
porsi[indeks]=jumlah;
harga[indeks]=13000;
total=total+(13000*jumlah);
break;
case 5:
menu[indeks]="Air Mineral";
System.out.print("Jumlah = ");
jumlah=sc.nextInt();
porsi[indeks]=jumlah;
harga[indeks]=3000;
total=total+(3000*jumlah);
break;
case 6:
menu[indeks]="Es Teh";
System.out.print("Jumlah = ");
jumlah=sc.nextInt();
porsi[indeks]=jumlah;
harga[indeks]=4000;
total=total+(4000*jumlah);
break;
case 7:
menu[indeks]="Es Jeruk";
System.out.print("Jumlah = ");
jumlah=sc.nextInt();
porsi[indeks]=jumlah;
harga[indeks]=5000;
total=total+(5000*jumlah);
break;
}
indeks++;
}while(pilih!=8);
//menampilkan makanan yang dibeli
System.out.println("===========================================");
System.out.println(" DAFTAR PEMBELIAN ");
System.out.println("===========================================");
for (int i = 0; i < indeks-1; i++){
System.out.println((i+1)+"."+menu[i]+"\t Rp "+harga[i]+"\t "+porsi[i]+"Porsi");
}
System.out.println("===========================================");
System.out.println("TOTAL BIAYA : Rp " + total);
System.out.println("===========================================");
}
}
Komentar
Posting Komentar