Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i am having a error in java that i do not know what it means, its multiple files. this is the error message Exception in
i am having a error in java that i do not know what it means, its multiple files. this is the error message "Exception in thread "main" java.util.NoSuchElementException
at java.basejavautil.Scanner.throwForScannerjava:
at java.basejavautil.Scanner.nextScannerjava:
at ShoppingCartManager.printMenuShoppingCartManagerjava:
at ShoppingCartManager.mainShoppingCartManagerjava:
this is my first file
import java.util.Scanner;
public class ShoppingCartManager
Implement the printMenu method. printMenu has a ShoppingCart parameter,
and outputs a menu of options to manipulate the shopping cart.
Each option is represented by a single character. Build and output the menu within the method.
public static void printMenuShoppingCart shoppingCart
System.out.println
MENU";
System.out.println a Add item to cart";
System.out.println d Remove item from cart";
System.out.println c Change item quantity";
System.out.println i Output items' descriptions";
System.out.println o Output shopping cart";
System.out.println q Quit";
System.out.println
Choose an option:";
Scanner scnr new Scanner Systemin;
Scanner scnrInt new Scanner Systemin;
Declare a new item to purchase.
ItemToPurchase item new ItemToPurchase ;
String Name ;
String Description ;
int Price ;
int Quantity ;
String option scnrnext ;
scnrnextLine;
switchoptioncharAt
case a:
System.out.println
ADD ITEM TO CART";
scnr new Scanner Systemin;
System.out.println Enter the item name:";
Name scnrnextLine ;
System.out.println Enter the item description:";
Description scnrnextLine ;
System.out.println Enter the item price:";
Price scnrInt.nextInt ;
System.out.println Enter the item quantity:";
Quantity scnrInt.nextInt ;
item new ItemToPurchase Name Description, Price,
Quantity;
shoppingCart.addItem item;
printMenu shoppingCart;
break;
case d:
System.out.println REMOVE ITEM FROM CART";
System.out.println Enter name of item to remove:";
scnrnextLine ;
String itemName scnrnextLine ;
shoppingCart.removeItem itemName;
printMenu shoppingCart;
break;
case c:
System.out.println CHANGE ITEM QUANTITY";
System.out.println Enter the item name:";
scnrnextLine ;
itemName scnrnextLine ;
shoppingCart.modifyItem itemName;
printMenu shoppingCart;
break;
case i:
System.out.println OUTPUT ITEM'S DESCRIPTIONS";
shoppingCart.printDescriptions ;
printMenu shoppingCart;
break;
case o:
System.out.println OUTPUT SHOPPING CART";
shoppingCart.printTotal ;
printMenu shoppingCart;
break;
default:
System.out.println Invalid Choice!";
printMenu shoppingCart;
System.out.println
;
public static void main Stringargs
Scanner scnr new Scanner Systemin;
System.out.println Enter customer's name:";
String customerName scnrnextLine ;
System.out.println Enter today's date:";
String currentDate scnrnextLine ;
System.out.println
Customer name: customerName;
System.out.println Todays date: currentDate;
Create a linked list shopping cart.
ShoppingCart shoppingCart new ShoppingCart customerName currentDate;
Print menu.
printMenu shoppingCart;
its too many character to add them all can you figure it out with this information?
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