Array Multi Dimensi 22082010014 RISMA PARAMESTI
package arraymultidimensi;
import java.util.Scanner;
public class Arraymultidimensi {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String transaksi[][]= new String [5][10];
int kode = 1001;
int harga = 0, total;
int baris=0, kolom=0;
int pilih=0, pilih2=0;
do{
System.out.println("");
System.out.println("================== SELAMAT DATANG ==================");
System.out.println("============ DI WARUNG MAKAN RISMA ===========");
System.out.println(" 1. Transaksi Baru ");
System.out.println(" 2. Rekap Transaksi ");
System.out.println(" 3. Selesai ");
System.out.println("====================================================");
System.out.print("Pilih : ");
pilih = sc.nextInt();
switch(pilih){
case 1:
if(baris<=2){
kolom=0;
transaksi[baris][kolom] = String.valueOf(kode);
kolom=1;
do{
if(kolom<=7){
System.out.println("");
System.out.println("\n========== DAFTAR MENU MAKANAN & MINUMAN ===========");
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. Kembali");
System.out.print("Pilih = ");
pilih2 = sc.nextInt();
switch(pilih2){
case 1:
transaksi[baris][kolom] = "Nasi Goreng";
break;
case 2:
transaksi[baris][kolom] = "Mie Goreng";
break;
case 3:
transaksi[baris][kolom] = "Mie Ayam";
break;
case 4 :
transaksi[baris][kolom] = "Ayam Geprek";
break;
case 5:
transaksi[baris][kolom] = "Air Mineral";
break;
case 6:
transaksi[baris][kolom] = "Es Teh";
break;
case 7:
transaksi[baris][kolom] = "Es Jeruk";
break;
case 8:
System.out.println("KEMBALI KE MENU UTAMA");
break;
}
kolom++;
}else {
System.out.println("Maaf Keranjang Penuh!");
break;
}
}while(pilih2 != 8);
baris++;
kode++;
}else{
System.out.println("MAAF TRANSAKSI PENUH");
}
break;
case 2:
System.out.println("REKAP TRANSAKSI");
System.out.println("KODE\tMENU MAKANAN % MINUMAN");
for(int i=0; i<baris; i++){
for(int j=0; j<7; j++){
if(transaksi[i][j] != null){
System.out.print(transaksi[i][j] + "\t");
}
}
System.out.println("");
}
break;
case 3:
System.out.println("========= Terima Kasih Atas Kunjungan Anda =========");
break;
}
}while(pilih != 3);
}
}
Komentar
Posting Komentar