Advertisement
JeffGrigg

2018-12-05 - Second Try #2

Dec 5th, 2018
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.57 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.         //int totalsnsckQty = 50;   // [This variable is unused.]
  18.  
  19.         System.out.println("1 total coin un the machine");
  20.         System.out.println("2 Profit/Losses");
  21.         System.out.println("please enter an option");
  22.         int option = input.nextInt();
  23.  
  24.         if (option == 0) {
  25.             createMenu();
  26.         } else if (option == 1) {
  27.             double totalCoin = 0;
  28.             for (int i = 0; i < 5; i++) {
  29.                 totalCoin += coinArr[i] * coinQtyArr[i];
  30.             }
  31.             System.out.println("the total coin in the machine are " + totalCoin);
  32.         } else if (option == 2) {
  33.             double profit = 0;
  34.             for (int i = 0; i < 5; i++) {
  35.                 profit += (itemPriceArr[i] * itemQtyArr[i]);
  36.             }
  37.             double losses = (singleitemprice * totalsnackQty);
  38.             System.out.println("the profit is " + profit + " the losses is " + losses);
  39.         } else {
  40.             System.out.println("invalid option please select another option");
  41.         }
  42.     }
  43.  
  44.     private static void createMenu() {
  45.         // ???
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement