import java.util.Scanner;
public class Pos {
static int cashAmount = 100000;
String[] menu;
int[] price;
int[] salesQuantity;
void showMenu(){
for (int i = 0; i < menu.length; i++) {
System.out.println(i + 1 + ". " + menu[i] + " : " + price[i] + "₩");
}
System.out.println();
}
void order(){
showMenu();
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
buy(a);
}
void buy(int a){
try {
cashAmount += price[a - 1];
salesQuantity[a - 1] += 1;
System.out.println("You ordered " + menu[a - 1]);
System.out.println("You pay for " + price[a - 1] + "₩");
System.out.println(menu[a -1] + " is here");
System.out.println();
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("You wrong order");
System.out.println("Please reorder");
System.out.println();
order();
}
}
void close(){
System.out.println("Today sale proceeds is " + cashAmount + "₩");
System.out.println("Sales status is ");
for (int i = 0; i < menu.length; i++) {
System.out.println("└ " + menu[i] + " : " + salesQuantity[i]);
}
}
}
public class Homework4 {
public static void main(String[] args) {
Pos pos1 = new Pos();
pos1.menu = new String[]{"Americano", "Latte", "MochaFrappuccino", "JavaChipFrappuccino", "ChamomileTea"};
pos1.price = new int[]{4500, 5000, 5900, 6300, 4500};
pos1.salesQuantity = new int[pos1.price.length];
pos1.order();
pos1.order();
pos1.order();
pos1.close();
}
}