Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Java Program that emulates an online shopping. There are fifteen different items in three different categories for sale, and each item with item
Write a Java Program that emulates an online shopping.
There are fifteen different items in three different categories for sale, and each item with item code, item name, item description, and unit price.
The input file is provided CSV format as shown:
Item Code Item Name Item Description Unit Price
E Laptop inch display GB RAM GB S
E Smartphoneinch display GB storage
E Tablet inch display GB storage
E Monitor inch Full HD display
E Keyboard Mechanical keyboard with RGB light
F Sofa seater sofa
F Dining TableWooden dining table
F Chair Ergonomic office chair
F Bed Queen size bed
F Bookshelf tier bookshelf
C Running ShoesLightweight running shoes
C Tshirt Cotton Tshirt
C Jeans Denim jeans
C Jacket Winter jacket
C Cap Baseball cap
Item codes that start with E does not have sales tax.
Item Code,Item Name,Item Description,Unit Price $
ELaptop,"inch display, GB RAM, GB SSD
The program must have at least two classes or more: Item and OnlineSale.
The Item class is for the item data with four attributes: itemCode, itemName, itemDescription, and unitPrice.
You are encouraged to include more classes.
Make the main class OnlineSale. The following shows a sample run:
$ javac OnlineSale.java
$ java OnlineSale
Welcome to MyLastName online sale system!
Beginning a new sale YN y ;both the upper and lower case should work
Enter product code: C ;the user input stays right to the message
item name: Running Shoes
Enter quantity:
item total: $ ;the output should be aligned properly
Enter Product code: C
item name: Winter jacket
Enter quantity:
item total: $
Enter product code:
Items list:
Running Shoes $
Winter jacket $
Subtotal $
Total with Tax $
Beginning a new sale YN Y
Enter product code: E
item name: Keyboard
Enter quantity:
item total: $
Enter product code:
Invalid product code
Enter product code: A
Invalid product code
Enter Product code: C
item name: Running Shoes
Enter quantity: a
Invalid quantity
Enter quantity:
item total: $
Enter product code:
Items list:
Keyboard $
Running Shoes $
Subtotal $
Total with Tax $
Beginning a new sale YN N
The total sale for the day is $
Thanks for using MyLastNames online sale system. Goodbye!
The example provided must run exact
In the sample run, the bold face letters are output from the sale system and nonbold italicized
letters are input from the user. The user enters to terminate each current sale. The system is
terminated if the user enters N on Beginning a new sale YN Then, the system prints out
the total sale amount of the day.
Your program should compile and run in the command line environment. All user input needs to be checked properly to avoid exceptions.
Suggestions: Provide methods or functions that perform the following tasks:
Read item data into items array
Accepts the item code for each item for sale
Get the item name from the item code and print the name
Accepts the quantity of the item
Computes the item total for each item
Get the subtotal of all items purchased
Computes the total sales amount with tax
Initialize the item purchase list for each new sale
Note:
Use arrays for the item data. That is you are not allowed to use other data types like
ArrayList, Vector, Set, etc.
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