Make a shopping cart program that implements the ArrayList class. Make a class named Item.java that contains the following data members, item_name, quantity, and price. Create the appropriate constructors and methods to initialize, access, and manipulate the data members, also create a toString method to print the item name, quantity, and price. Create an ArrayList of Items in the Main. For the INPUT The user will enter the item name, quantity, and price of each item. A 'Y' will add another item to the shopping cart, and 'N' will stop the input. For the OUTPUT The program then lists the items in the shopping cart using the toString method in the Item class. Calculate for the subtotal and total of the items in the cart. Format your toString method to have a double tab, "\t\t", after the item name, single tab, "\t", after quantity and double tab, "\t\t", after price. EXAMPLE INPUT Pencil 2 15.25 y Yellow Paper 1 50.00 n OUTPUT Pencil 2 15.25 30.50 Yellow Paper 1 50.00 50.00 Total amount in shopping cart: 80.50
Make a shopping cart
Make a class named Item.java that contains the following data members, item_name, quantity, and price. Create the appropriate constructors and methods to initialize, access, and manipulate the data members, also create a toString method to print the item name, quantity, and price. Create an ArrayList of Items in the Main.
For the INPUT
The user will enter the item name, quantity, and price of each item. A 'Y' will add another item to the shopping cart, and 'N' will stop the input.
For the OUTPUT
The program then lists the items in the shopping cart using the toString method in the Item class. Calculate for the subtotal and total of the items in the cart.
Format your toString method to have a double tab, "\t\t", after the item name, single tab, "\t", after quantity and double tab, "\t\t", after price.
EXAMPLE
INPUT
Pencil
2
15.25
y
Yellow Paper
1
50.00
n
OUTPUT
Pencil 2 15.25 30.50
Yellow Paper 1 50.00 50.00
Total amount in shopping cart: 80.50
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images