import java.util.Scanner; public class SecondTry { static Scanner input = new Scanner(System.in); static int singleitemprice = 3; static int totalsnackQty = 5; static int[] coinArr = {1, 2, 3, 4, 5}; static int[] coinQtyArr = {1, 2, 3, 4, 5}; static int[] itemPriceArr = {1, 2, 3, 4, 5}; static int[] itemQtyArr = {1, 2, 3, 4, 5}; public static void main(String[] args) { subMenu(); } private static void subMenu() { System.out.println("1 total coin un the machine \n" + "2 Profit/Losses"); //int totalsnsckQty = 50; // [This variable is unused.] double totalCoin = 0; double losses = (singleitemprice * totalsnackQty); double profit = 0; { // <- This bracket is pointless. System.out.println("please enter an option"); int option = input.nextInt(); for (int i = 0; i < 5; i++) { totalCoin += coinArr[i] * coinQtyArr[i]; if (option == 1) { System.out.println("the total coin in the machine are" + totalCoin); } else if (option == 0) { createMenu(); } else if (option == 2) { for (int j = 0; j < 5; j++) profit += (itemPriceArr[j] * itemQtyArr[j]); System.out.println("the profit is" + profit + "the losses is" + losses); } } if (option > 2) { System.out.println("invalid option please select another option"); } } } private static void createMenu() { // ??? } }