Answered step by step
Verified Expert Solution
Link Copied!

Question

00
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 NameItem DescriptionUnit Price
E001 Laptop 14-inch display 8GB RAM 256GB S1200
E002 Smartphone6.5-inch display 128GB storage 800
E003 Tablet 10-inch display 64GB storage 300
F001 Sofa 3-seater sofa 500
F002 Dining TableWooden dining table 6350
F003 Chair Ergonomic office chair 120
Item codes that start with E does not have 6% sales tax.
Item Code,Item Name,Item Description,Unit Price ($)
E001,Laptop,"14-inch display, 8GB RAM, 256GB SSD",1200
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 (Y/N) y ;both the upper and lower case should work
--------------------
Enter product code: C0001 ;the user input stays right to the message
item name: Running Shoes
Enter quantity: 1
item total: $ 70.00 ;the output should be aligned properly
Enter Product code: C004
item name: Winter jacket
Enter quantity: 1
item total: $ 100.00
Enter product code: -1
----------------------------
Items list:
1 Running Shoes $ 70.00
1 Winter jacket $ 100.00
Subtotal $ 170.00
Total with Tax (6%) $ 180,20
----------------------------
Beginning a new sale (Y/N) Y
--------------------
Enter product code: E005
item name: Keyboard
Enter quantity: 2
item total: $ 160.00
Enter product code: 11
!!! Invalid product code
Enter product code: A
!!! Invalid product code
Enter Product code: C001
item name: Running Shoes
Enter quantity: a
!!! Invalid quantity
Enter quantity: 1
item total: $ 70.00
Enter product code: -1
----------------------------
Items list:
2 Keyboard $ 160.00
1 Running Shoes $ 100.00
Subtotal $ 260.00
Total with Tax (6%) $ 266,00
----------------------------
Beginning a new sale (Y/N) N
The total sale for the day is $ 446.20
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 non-bold italicized
letters are input from the user. The user enters -1 to terminate each current sale. The system is
terminated if the user enters 'N' on Beginning a new sale (Y/N). 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions