Advertisement
JeffGrigg

2018-12-05 - Second Try

Dec 5th, 2018
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.67 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SecondTry {
  4.     static Scanner input = new Scanner(System.in);
  5.     static int singleitemprice = 3;
  6.     static int totalsnackQty = 5;
  7.     static int[] coinArr = {1, 2, 3, 4, 5};
  8.     static int[] coinQtyArr = {1, 2, 3, 4, 5};
  9.     static int[] itemPriceArr = {1, 2, 3, 4, 5};
  10.     static int[] itemQtyArr = {1, 2, 3, 4, 5};
  11.  
  12.     public static void main(String[] args) {
  13.         subMenu();
  14.     }
  15.  
  16.     private static void subMenu() {
  17.         System.out.println("1 total coin un the machine \n" + "2 Profit/Losses");
  18.         //int totalsnsckQty = 50;   // [This variable is unused.]
  19.         double totalCoin = 0;
  20.         double losses = (singleitemprice * totalsnackQty);
  21.         double profit = 0;
  22.         { // <- This bracket is pointless.
  23.             System.out.println("please enter an option");
  24.             int option = input.nextInt();
  25.             for (int i = 0; i < 5; i++) {
  26.                 totalCoin += coinArr[i] * coinQtyArr[i];
  27.                 if (option == 1) {
  28.                     System.out.println("the total coin in the machine are" + totalCoin);
  29.                 } else if (option == 0) {
  30.                     createMenu();
  31.                 } else if (option == 2) {
  32.                     for (int j = 0; j < 5; j++)
  33.                         profit += (itemPriceArr[j] * itemQtyArr[j]);
  34.                     System.out.println("the profit is" + profit + "the losses is" + losses);
  35.                 }
  36.             }
  37.             if (option > 2) {
  38.                 System.out.println("invalid option please select another option");
  39.             }
  40.         }
  41.     }
  42.  
  43.     private static void createMenu() {
  44.         // ???
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement