JeffGrigg icon

2018-12-05 - Second Try #2

JeffGrigg | PRO | 12/06/18 12:48:23 AM UTC | 0 ⭐ | 960 👁️ | 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() {
        //int totalsnsckQty = 50;   // [This variable is unused.]
 
        System.out.println("1 total coin un the machine");
        System.out.println("2 Profit/Losses");
        System.out.println("please enter an option");
        int option = input.nextInt();
 
        if (option == 0) {
            createMenu();
        } else if (option == 1) {
            double totalCoin = 0;
            for (int i = 0; i < 5; i++) {
                totalCoin += coinArr[i] * coinQtyArr[i];
            }
            System.out.println("the total coin in the machine are " + totalCoin);
        } else if (option == 2) {
            double profit = 0;
            for (int i = 0; i < 5; i++) {
                profit += (itemPriceArr[i] * itemQtyArr[i]);
            }
            double losses = (singleitemprice * totalsnackQty);
            System.out.println("the profit is " + profit + " the losses is " + losses);
        } else {
            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

    |

    👍

    /

    👎