Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i am having an error with a multiple file code in java. please only edit things to fix the errors and not changing my variable
i am having an error with a multiple file code in java. please only edit things to fix the errors and not changing my variable names. here is my error "ShoppingCartManager.java:: error: variable option is already defined in method printMenuShoppingCart
String option scnrnext ;
ShoppingCartManager.java:: error: cannot find symbol
Price scnrInt.nextInt ;
symbol: variable scnrInt
location: class ShoppingCartManager
ShoppingCartManager.java:: error: cannot find symbol
Quantity scnrInt.nextInt ;
symbol: variable scnrInt
location: class ShoppingCartManager
errors"
and heres my code
import java.util.Scanner;
public class ShoppingCartManager
public static void printMenuShoppingCart shoppingCart
System.out.printlnMENU;
System.out.printlna Add item to cart";
System.out.printlnd Remove item from cart";
System.out.printlnc Change item quantity";
System.out.printlni Output items' descriptions";
System.out.printlno Output shopping cart";
System.out.printlnq Quit";
System.out.printlnChoose an option:";
Scanner scnr new ScannerSystemin;
String option scnrnextLine;
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;
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