import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int balance = 1000;
int hundred = 10;
int fifty = 10;
int five = 10;
ArrayList<String> names = new ArrayList<>();
names.add("Cola");
names.add("Bread");
names.add("Egg");
ArrayList<Integer> prices = new ArrayList<>();
prices.add(65);
prices.add(15);
prices.add(10);
ArrayList<Integer> quantities = new ArrayList<>();
quantities.add(100);
quantities.add(50);
quantities.add(30);
while (true) {
System.out.println("Code: ");
int code = in.nextInt();
if (code >= 0 && code < quantities.size()) {
System.out.println("Balance: " + balance);
System.out.println("Cost: " + prices.get(code));
System.out.println("Quantity:");
int quantity = in.nextInt();
System.out.println("Receipt:");
System.out.println("Name: " + names.get(code) + " Quantity: " + quantities +
" Price: " + prices.get(code) + " Total: " + (quantity * prices.get(code)));
hundred += (quantity * prices.get(code)) / 100;
fifty += ((quantity * prices.get(code)) % 100) / 50;
five += (((quantity * prices.get(code)) % 100) % 50) / 5;
System.out.println("Change: " + (balance - quantity * prices.get(code)));
} else if (code == 98989) {
System.out.println("Hola-Lula, North pole");
for (int i = 0; i < quantities.size(); i++) {
System.out.println(i + "Name: " + names.get(i) + " Quantity: " + quantities.get(i) +
" Price: " + prices.get(i));
}
System.out.println("Login confirmation code:");
int confirmationCode = in.nextInt();
if (confirmationCode == 89898) {
System.out.println("1. Restock\n" +
"2. Add item\n" +
"3. Change price\n" +
"4. Cash out\n" +
"5. Cash in\n" +
"6. Print summary\n" +
"7. Amount of cash\n" +
"8. Print only restocking\n" +
"9. Exit");
switch (in.nextInt()) {
case 1:
System.out.println("Code, Quantity: ");
quantities.set(in.nextInt(), in.nextInt());
break;
case 2:
System.out.println("Name: ");
names.add(in.next());
System.out.println("Quantity: ");
quantities.add(in.nextInt());
System.out.println("Price: ");
prices.add(in.nextInt());
break;
case 3:
System.out.println("Code, New Price: ");
prices.set(in.nextInt(), in.nextInt());
break;
case 4:
System.out.println("1. 100\n" +
"2. 50\n" +
"3. 5");
System.out.println("Amount: ");
switch (in.nextInt()) {
case 100:
hundred -= in.nextInt();
break;
case 50:
fifty -= in.nextInt();
break;
case 5:
five -= in.nextInt();
break;
}
break;
case 5:
System.out.println("1. 100\n" +
"2. 50\n" +
"3. 5");
System.out.println("Amount: ");
switch (in.nextInt()) {
case 100:
hundred += in.nextInt();
break;
case 50:
fifty += in.nextInt();
break;
case 5:
five += in.nextInt();
break;
}
break;
case 6:
System.out.println("Summary:");
for (int i = 0; i < quantities.size(); i++) {
System.out.println(i + "Name: " + names.get(i) + " Quantity: " + quantities.get(i) +
" Price: " + prices.get(i));
}
break;
case 7:
System.out.println("100: " + hundred);
System.out.println("50: " + fifty);
System.out.println("5: " + five);
break;
case 8:
System.out.println("Re-order:");
for (int i = 0; i < quantities.size(); i++) {
if (quantities.get(i) < 25) {
System.out.println(i);
}
}
break;
case 9:
System.exit(0);
}
}
}
}
}
}
Comments
Leave a comment