Question: DATA TYPE CLASS Class SU2022ProductSU_yourLastName This class holds two arrays : -one array size 3 that keeps the number of units of 3 product sizes
DATA TYPE CLASS
Class SU2022ProductSU_yourLastName
This class holds two arrays:
-one array size 3 that keeps the number of units of 3 product sizes
-one array size 3 that keeps the prices of 3 product sizes
*at index 0 of these arrays will store number of units and unit price of SMALL size
*at index 1 of these arrays will store number of units and unit price of MEDIUM size
*at index 2 of these arrays will store number of units and unit price of LARGE size
The class SU2022ProductSU_yourLastName also has no-argument constructor, parameterized constructor, method to generate the current day, method calculates and prints out the sale receipt, method calculates and prints out the day report, method calculate and prints out the compare 2 days report, method toFile to create the line to write to the output file.
Method generates the current day:
public String getCurrentDate()
{
DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
Date date = new Date();
return formatter.format(date);
}
Method calculates and prints the sale receipt:
-calculate the sale amount of each size:
Money sold small size = array Unit at index 0 * array Price at index 0
Money sold medium size = array Unit at index 1 * array Price at index 1
Money sold large size = array Unit at index 2 * array Price at index 2
-Calculate subtotal = Money sold small size + Money sold medium size + Money sold large size
-calculate tax = subtotal * 8.25%
-calculate total = subtotal + tax
-create a String of the output in the following receipt output:
File SU2022SaleProductSU_Application_White.java
SU2022 Sale Product SU Receipt McKINLEY WHITE
Day:06/01/2022 - Transaction #: 0001
-------------------------------------------
SMALL (11.29) 12 135.48
MEDIUM (12.79) 15 191.85
LARGE (13.59) 10 135.90
-------------------------------------------
Subtotal: 463.23
Tax: 38.22
Total: 501.45
Money Paid: 510.00
Change: 8.55
Method toFile() to create one line to write to file in the following format:
Transaction number numberSmallSize numberMediumSize numberLargeSize
0001 12 15 10
Method Print day report
-calculate subtotal, tax, total as in the method print receipt
-create output String in the following format:
SU2022SaleProductSU_Application_White.java
SALE PRODUCT SU REPORT McKINLEY WHITE
Day Report: 05/31/2022
-------------------------------------------
SMALL (11.29) 433 4888.57
MEDIUM (12.79) 440 5627.60
LARGE (13.59) 476 6468.84
-------------------------------------------
Subtotal: 16985.01
Tax: 1401.26
Total: 18386.27
Method Compare Two Days
File SU2022SaleProductSU_Application_White.java
SALE PRODUCT SU COMPARE DAYS REPORT McKINLEY WHITE
COMPARE DAYS: 05/31/2022 and 06/01/2022
--------------------------------------------------------------------------------------------
SALE IN 05/31/2022 SALE IN 06/01/2022 DIFFERENCE PERCENTAGE
SMALL ($11.29) 433 4888.57 492 5554.68 59 13.63%
MEDIUM ($12.79) 440 5627.60 508 6497.32 68 15.45%
LARGE ($13.59) 476 6468.84 478 6496.02 2 0.42%
--------------------------------------------------------------------------------------------
Subtotal: 16985.01 18548.02
Tax: 1401.26 1530.21
Total: 18386.27 20078.23
DRIVER CLASS
Class SU2022SaleProductSU_Application_yourLastName includes function main()
A shop sales product SU in 3 sizes: SMALL, MEDIUM, and LARGE in the following prices:
-size SMALL: $11.29
-size MEDIUM: $12.79
-size LARGE: $13.59
Create a float array size 3 to store 3 above prices, for example, arrayPrice
First, the application must display the main menu, then read the task selected from users. After finishing one task, the main menu must be redisplayed to allow users to select other tasks. The application will be terminated if users select 0 from the main menu.
File: SU2022SaleProductSU_Application_White.java
PRODUCT SU SHOP MAIN MENU McKINLEY WHITE
Current Date: 06/02/2022
-----------------------------------------------
1. Sale Product SU
2. Ending Day Sale Report
3. Compare Sale In Two Days Report
0. Exit
Enter a number from 1 to 3 to select a task:
TASK1: SALE PRODUCT SU
When users select 1 to choose the task SALE PRODUCT SU, create an int array size 3 to store the numbers of units that users will buy, for example, arrayUnit, to store number of units in size small, number of units in size medium and number of units in size large. Then, all numbers of units start at 0.
Display the list of the product size as below to allow users to select products. After users enter a number of one size, the application must redisplay the Product SU menu to allow users to select other size to order until the users select 0.
When users select a size more than once, for example, users select 1 for size SMALL twice with two numbers entered are 8 and 4 then the number of units in size SMALL should be 8 + 4 = 12 units.
SU2022SaleProductSU_Application_White.java
PRODUCT SU MENU - McKINLEY WHITE
Today: 06/02/2022
-----------------------------
1.SMALL - $11.29
2.MEDIUM - $12.79
3.LARGE - $13.59
0.Exit
Enter a number from 1 to 3 to select product size:
When users select 0 on the Product SU menu, close the menu and create an object of datatype class SU2022ProductSU_yourLastName to pass the arrayUnit and the arrayPrice as parameters
The transaction is created in the form of 4 digits: 0001, 0002, 0010, 0011, etc.
Use the object to access the method getTotal() of the datatype class to get and display the total charge of the order and display the message to ask and read the pay amount
Use the object to access the method printReceipt() of the datatype class to pass the transaction number and the pay amount as parameters to print out the receipt.
Open file daySale_06012022.txt to write.
Use the object to access the method toFile() to have the line to write this line to the file. Close file.
TASK2: REPORT DAY SALE PRODUCTS
-Display message and read from the keyboard for the file name that stored all the transactions sold for one day that are written from task 1. The file name in the format daySale_MMddyyyy.txt
-You can split the file name to get MMddyyyy then create the day of the report: MM/dd/yyy
-create one array size 3 to store 3 totals of units of 3 sizes that read all lines in file, for example, arrayTotalUnits
-open file with entered file name to read
-if the file exists, create while loop to read file until end of file
*For each line, split information in to 4 pieces
For example:
0001 20 10 12 20 is the number of small size, 10 is the number of medium size, 12 is the number of large size
-Add up number of small size to arrayTotalUnits [0], number of medium size to arrayTotalUnits[1], and number of large size to arrayTotalUnits[2]
-After reading all file, close file then creates the object of class SU2022ProductSU_yourLastName to pass in two arrays: arrayTotalUnits and arrayPrice as parameters
-Use the object to access method printReport() of class SU2022ProductSU_yourLastname that accepts the day MM/dd/yyyy as parameter to print out the day report
TASK3: COMPARE TWO DAYS REPORT
-display and read two file names from the keyboard that kept the sale transaction in two days users want to compare. The file names are in the format: daySale_MMddyyyy
-split from the file name to have two days to compare in the format MMddyyyy then create the days in the format MM/dd/yyyy
-Do the same task2 on each file to create the object of datatype class to pass the arrayTotalUnits and arrayPrice in then we have 2 objects from reading 2 files.
-Use one object of early day to access the method compareReport() of datatype class that accept the object of later day, and two days to print out the report.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
