JeffGrigg icon

2018-12-05 - Second Try

JeffGrigg | PRO | 12/06/18 12:40:54 AM UTC | 0 ⭐ | 999 👁️ | Never ⏰ | []
Java 5 |

0 B

|

None

|

0 👍

/

0 👎

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() {
        // ???
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎