Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I ' m having trouble trying to solve these errors within my code. String name = scanner.nextLine ( ) ; System.out.println ( Please enter

I'm having trouble trying to solve these errors within my code. String name = scanner.nextLine();
System.out.println("Please enter the price for "+ name +";
double price = scanner.nextDouble();
scanner.nextLine(); // Consume nevline left-over
System.out.println("Please enter the base yogurt flavor for "+ name +";
String base = scanner.nextLine();
ArrayList
This is my Menu.java code that I have so far.
Everytime I go to run the code, I receive this error shown below.
sre > mein > menu > FrozenYogurt.jevepublic class FrozenYogurt extends MenuItem {private String[] toppings; super(name, price); this.toppings = toppings;public String getBase(){} return toppings;public void addTopping(String topping){ newToppings[toppings.length]= topping;}public String toString(){ "Price : $"+ getPrice()+"
"+ "Topping : "+ String.join(",", toppings)+"
";}
Annotated Matches View (6 of 19 matches found)
(Matches are uppercased and indicated with *** before and after the match)
========================================================================
Welcome to the Menu
Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit
Please ***CHOOSE*** from the above actions: Please enter the name of the frozen ***YOGURT***:
Please enter the ***PRICE*** for Berry Delight:
Please enter the ***BASE*** yogurt flavor for Berry Delight:
Please enter a ***TOPPING*** for Berry Delight (enter 'done' to finish):
Please enter a topping for Berry Delight (enter 'done' to finish):
Please enter a topping for Berry Delight (enter 'done' to finish):
Please enter a topping for Berry Delight (enter 'done' to finish):
Please enter a topping for Berry Delight (enter 'done' to finish):
Please enter a topping for Berry Delight (enter 'done' to finish):
Please enter a topping for Berry Delight (enter 'done' to finish):
Please enter a topping for Berry Delight (enter 'done' to finish):
Please enter a topping for Berry Delight (enter 'done' to finish):
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:
Missing: another topping
Missing: additional
Missing: another topping
Missing: additional
Missing: another topping
Missing: choose
Missing: Displaying
***1***540)
at Menu.addFrozenYogurt(Menu.java:71)
at Menu.main(Menu.java:170)
Missing: Berry Delight
Missing: 5.48
Missing: vanilla
Missing: blueberries, blackberries, strawberries
Missing: choose
Missing: Thank
The codes I've used are all shown below.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions