Answered step by step
Verified Expert Solution
Question
1 Approved Answer
for (; numberOfSnacks >0; numberOfSnacks--) { System.out.println(Enter snack selection:); input.nextLine(); String snackType = input.nextLine(); if(snackType.equals(A1) || snackType.equals(A2) || snackType.equals(A3)) { System.out.println(--------------------------); System.out.println(----Selection +snackType+----); System.out.println(--------------------------); System.out.println(
for (; numberOfSnacks >0; numberOfSnacks--) { System.out.println("Enter snack selection:"); input.nextLine(); String snackType = input.nextLine(); if(snackType.equals("A1") || snackType.equals("A2") || snackType.equals("A3")) { System.out.println("--------------------------"); System.out.println("----Selection" +snackType+"----"); System.out.println("--------------------------"); System.out.println(" Snack Item:"+" "+Snack1); System.out.println(" Snack Price:"+" "+POTATO_CHIPS); System.out.println(""); potatoChipCount++; snackCount++; totalAmount += POTATO_CHIPS; }//Potato Chips Selection else if(snackType.equals("B1") || snackType.equals("B2") || snackType.equals("B3")) { System.out.println("-----------------------"); System.out.println("----Selection"+" "+snackType+"----"); System.out.println("-----------------------"); System.out.println(" Snack Item:"+" "+Snack2); System.out.println(" Snack Price:"+" "+PRETZELS); System.out.println(""); pretzelCount++; snackCount++; totalAmount += PRETZELS; }//Pretzel selection else if(snackType.equals("C1") || snackType.equals("C2") || snackType.equals("C3")) { System.out.println("-----------------------"); System.out.println("----Selection"+" "+snackType+"----"); System.out.println("-----------------------"); System.out.println(" Snack Item:"+" "+Snack3); System.out.println(" Snack Price:"+" "+KIND_BAR); System.out.println(""); kindBarCount++; snackCount++; totalAmount += KIND_BAR; }//Kind Bar selection else if(snackType.equals("999")) { //Print receipt System.out.println("Total Sales ="+" "+ totalAmount); System.out.println("Total Number of Snacks Sold ="+" "+ snackCount); System.out.println(potatoChipCount+" "+ Snack1); System.out.println(pretzelCount+" "+ Snack2); System.out.println(kindBarCount+" "+ Snack3); }//else 999 else { input.nextLine(); System.out.println("Invalid Snack Type. Pleas pick A1-A3, B1-B3, or C1-C3"); }//Else }//For loop Vending
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started