Computer Programming

Aanand
Project.docx

COSC 1437 – PROJECT

TITLE

File access – Sale ProductSU21 Service

HOW TO DO PROJECT

*From now and on yourLastName will be changed to your last name.

*Your program should change White to your last name.

*Your program should change McKINLEY WHITE to your name.

*Change Mary Lane to the name of user who is using the Investment Application entered from the keyboard.

*Write the file name as the first comment line at the top of the program.

*After running your program, get the picture of the output window from your program with your name on to paste at the bottom of the pseudo-code to turn in.

*Step1: Read the requirement of each part; create the UML of data type class, write the pseudo-code of driver class in a word document by listing the step by step what you suppose to do in main() and then save it with the name as Project_pseudoCode_yourLastName.

*Step2:

-start editor (for example eClipse) create the project with the following project name:

SU2021_PROJECT_yourLastName

-add data type class:

PRODUCTSU21_yourLastName

-add a driver class (that contain main()

Part 2: SaleProductSU21Service_yourLastName

*Step3: follow step by step in the pseudo-code (or the flowchart) to write the java code in main() or driver class.

*Step:4 compile and run the program.

*Step5: debug if there are any errors to complete the program.

PROJECT INSTRUCTION

The SU21Product Company sales two product models, SU21ProductA and SU21ProductB.

The company asks for the application that helps the company to do some tasks that list in the following menu:

File SaleProductSU21Service_White.java

SU21Product Company – McKINLEY WHITE

-------------------------------------------

1. Sale Product

2. Day Sale Report

3. Month Sale Report.

4. Compare Two Months Report.

0. Exit

After finishing one task, the program should redisplay the menu to allow users to continue using the program to select other task until users select exit to terminate the program

You have to use Object Oriented Programming by providing the data type class and the driver class.

You cannot use any data structure in this project. You have to the objects of data type and at least 3 user-defined functions in the driver class

DATA TYPE CLASS

Class ProductSU21_yourLastName holds the following information:

model(char) : can be ‘A’ or ‘B’

units (int): number of units

unitPrice(float): the price of each product

*provide no-argument constructor, parameterized constructor

*provide accessor methods for getUnits() to return value of units

*provide method getMoney() to return the money: money = unitPrice * units

*provide method toString() return output string in the following format:

Where second information is unit price, third information is number of sold units, the last information is money:

If model is ‘A’ display:

SU21ProductA 219.99 12 2639.88

If model is ‘B’ display:

SU21ProductB 350.99 10 3509.90

DRIVER CLASS:

Class SaleProductSU21Service_yourLastName

First, get current date and start transaction number at 0 then display the menu of tasks.

From the main menu, users select one task by typing number 0 to 4:

Task1: SALE PRODUCT

Display the Product Menu to allow users to select the model to buy by typing a number 0 to 2. After finishing one type, redisplay the Product Menu to allow users continue to buy more products:

File SaleProductSU21Service_White.java

SU21Product Menu – McKINLEY WHITE

Day:06/11/2021

-------------------------------------------

1. SU21Product A

2. SU21Product B

0. Exit

Type 1, 2 or 0 to continue:

Type 1: this means users select the SU21ProductA

Type 2: this means users select the SU21ProductB

Type 0: this means users finish and wait for the receipt

When users type 1 or 2: display message to ask for the number of units they want to buy and read the number

If users select a type more than one time, the number of units should be added up with the previous number.

For example, users select 1 then enter 10 units. Then, users select 1 again at the Product menu and enter 5 units. This mean that the users buy 15 units, NOT 5 units.

When users type 0: create the object of SU21ProductA and create the object of SU21ProductB by pass the type and number of units in the objects

*Print out the receipt:

-Before print out the receipt, find the money on SU21ProductA and the money on SU21ProductB by use the object to access the method getMoney()

-calculate the subtotal = money on SU21ProductA + money on SU21ProductB

-calculate the tax amount = subtotal * 8.25%

-calculate the total = subtotal + tax amount

-Transaction number 1 will be display as a string “0001”, next receipt of next transaction will be “0002”, etc.

-The price of SU21ProductA is 219.99 and the price of SU21ProductB is 350.99

-Display the total (6657.14) and display the message to ask for Money Paid (6700.00)to calculate the c

change = money paid - total

File SaleProductSU21Service_White.java

Sale SU21Product Receipt – McKINLEY WHITE

Day: 06/01/2021 0001

-------------------------------------------

SU21ProductA 219.99 12 2639.88

SU21ProductB 350.99 10 3509.90

-------------------------------------------

Subtotal: 6149.78

Tax: 507.36

Total: 6657.14

Money Paid: 6700.00

Change: 42.86

*Open output file in append mode name dayFile_MMDDYYY.txt where MMDDYY is d from current date.

Write one line to the file with 3 information separated by one space in the following the close file

Transaction numberOfSU21ProductA numberOfSU21Poduct

Task2: DAY SALE REPORT

Read the date from users in the format MMDDYYYY

Create the file name: dayFile_MMDDYYYY.txt

Check if file does not exist, display message “File does not exist”.

If the file exists, open file to read:

-Each line stores the information of one transaction from Task1.

-For each line, split to get numberA and numberB that are the numbers of units of each product model.

-the add up all these numbers into two sum_numberA and sum_numberB.

-At the end of file, there are sum_numberA and sum_numberB. Create one object of SU21Product of model A and one object of SU21Product of model B

-find the money on SU21ProductA and the money on SU21ProductB by use these objects to access the method getMoney()

-calculate the subtotal = money on SU21ProductA + money on SU21ProductB

-calculate the tax amount = subtotal * 8.25%

-calculate the total = subtotal + tax amount

-print the day report in the following format:

File SaleProductSU21Service_White.java

Day: 06/01/2021

-------------------------------------------

SU21ProductA 219.99 67 14739.33

SU21ProductB 350.99 57 20006.43

-------------------------------------------

Subtotal: 34745.76

Tax: 2866.53

Total: 37612.28

3. MONTH SALE REPORT

Do the same as task2 to get the Month Sale Report

The file name should be monthFile_052021.txt

File SaleProductSU21Service_White.java

SU21Product Month Report – McKINLEY WHITE

Day: 05/2021

---------------------------------------------

SU21ProductA 219.99 3972 873800.31

SU21ProductB 350.99 4096 1437655.00

---------------------------------------------

Subtotal: 2311455.25

Tax: 190695.06

Total: 2502150.25

4. COMPARE TWO MONTHS REPORT

-Ask users to provide the first month and the second month that they want to compare in the format MMYYYY

To create the file name monthFile_MMYYYY, for example, monthFile_042021.txt or monthFile_052021.txt

-Check file exists. If one of these two files do not exist, display message “File does not exist”

-If both files exist, open, and read each line, split information and add up number of each product. At the end of

the first file there are numberA1 and nunberB1 that are the number of the model A and the number of the model B. At the end of the second file there are numberA2 and numberB2.

-On each product model, calculate the different between numbers sold from two months:

Different between 2 months of model A = number of model A in 2nd month – number of model A in 1st month

Different between 2 months of model B = number of model B in 2nd month – number of model B in 1st month

-On each product model, calculate the percentage that reference to see how much percentage increasing:

Percentage Increase of model A = 100 * different between 2 month of model A / number of model A in 1st month

Percentage Increase of model B = 100 * different between 2 month of model B / number of model B in 1st month

-Display the report:

File SaleProductSU21Service_White.java

SU21Product Compare Months Report – McKINLEY WHITE

Months: 04/2021 05/2021 Different %Status

----------------------------------------------------------

SU21ProductA: 3749 3972 223 5.95%

SU21ProductB: 3675 4096 421 11.46%

HOW TO TURN IN THE LAB

You should turn in the following files: (yourLastName should be your last name)

SU2021PROJECT _YourLastName.docx (for UML, Pseudo-code, and the output pictures)

ProductSU21_yourLastName.java

SaleProductSU21Service_yourLastName.java

ProductSU21_yourLastName.class

SaleProductSU21Service_yourLastName.class

IF YOU GET ANY PROBLEM TO SUBMIT FILEs .class YOU CAN COMPRESS ALL PROJECT INTO ONE FILE .zip or .rar TO UPLOAD TO eCampus

HOW TO GRADE THE LAB

Topic

Scores

turn in on time

8

Submit all files requested with correct names

3

compile success with all the requirements

10

UML Pseudo-code or flowchart and output pictures

6

Write the comment in the program, name file is at top

5

Using at least 3 user-defined functions and call them in main()

6

Manage main menu to re-display after finishing each task and terminate when users select exit

2

TASK1 Month Sale Report: read input from the keyboard, calculate, print the report on screen, write one line to file, close files

10

TASK2 Year Sale Report: read input file, store in array, read each element of the array, calculate, print the year report, close files

12

TASK3 Compare Year Sale report: read 2 files, create object, place objects to 2 arrays, Read 2 arrays, calculate, print 2 reports for 2 models, , close files

10

Output as requested

8

PROJECT SCORES

80 POINTS