Question: ( CODE CONTINUED ) tempSnack = scnr . nextLine ( ) ; System.out.println ( Please Enter Snack Price: ) ; tempPrice = scnr

(CODE CONTINUED)
tempSnack = scnr.nextLine();
System.out.println("Please Enter Snack Price: ");
tempPrice = scnr.nextDouble();
if (health.equalsIgnoreCase("healthy")){
snack newSnack = new HealthySnack(tempSnack, tempPrice);
System.out.println(newSnack);
System.out.println();
}else if(health.equalsIgnoreCase("unhealthy")){
snack newSnack = new UnhealthySnack(tempSnack, tempPrice);
System.out.println(newSnack);
System.out.println();
}else {
System.out.println("Please enter 'healthy' or 'unhealthy'");
}
}
public static void printSnack(){
System.out.println("Your Snack List:");
selectedSnacks.forEach((key, value)-> System.out.println(key +" $"+ value));
}
public static void modifyList(){
String tempName;
double tempPrice;
Scanner scnr = new Scanner(System.in);
System.out.println("What snack would you like to remove?");
System.out.println("Pleae input a snack name from your list");
tempName = scnr.nextLine();
//selectedSnacks.forEach((key, value)-> selectedSnacks.equals(tempName));
selectedSnacks.entrySet().removeIf(entry -> entry.getKey().equalsIgnoreCase(tempName));
}
public static void finalPrint(){
// TODO Auto-generated method stub
Scanner scnr = new Scanner(System.in);
String answer;
String secondAnswer;
while (!validInput){
System.out.println("Would you like to place or modify an order?");
System.out.println("Please answer with yes or no");
answer = scnr.nextLine();
secondInput = false;
if (answer.equalsIgnoreCase("YES")){
validInput = true;
while (!secondInput){
System.out.println("Are you placing a new order or modifying an existing order?");
System.out.println("Please answer with placing or modifying");
secondAnswer = scnr.nextLine();
try {
if (secondAnswer.equalsIgnoreCase("modifying")){
secondInput = true;
// Code for modifying an existing list
System.out.println("Modifying an order with no prior orders will result in a default order.");
System.out.println();
System.out.println("This is your current list");
snack.baseList();
System.out.println();
receipt.howManyToModify();
SnackOrder.printSnack();
System.out.println();
validInput = false;
} else if (secondAnswer.equalsIgnoreCase("placing")){
secondInput = true;
// Code for creating a new list
//...
selectedSnacks.clear();
receipt.howManyToPurchase();
receipt.printDetails();
SnackOrder.printSnack();
receipt.sumTotal();
validInput = false;
} else {
System.out.println("Please enter a valid input (modifying or placing).
");
secondInput = false;
}
} catch (Exception e){
System.out.println("An error occurred: "+ e.getMessage());
}
}
}else if (answer.equalsIgnoreCase("NO")){
System.out.println("Thank you for using our service have a nice day!");
validInput = true;
} else {
System.out.println("please enter a valid input
");
}
}
PLEASE MAKE A FLOWCHART FOR THIS JAVA CODE. THANK YOU
( CODE CONTINUED ) tempSnack = scnr . nextLine (

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!