This is the individual project that helps you to review what we have learned from the course. Start the project early as you can and enjoy it.

OBJECTIVES

Doing this project, students will have the chances to practice with the following concepts; therefore, you should review them when you are working on the project:

  • Repetition structures: using for, while, or do..while loop
  • Selection structure: using if, if else, or switch statement
  • Read data from keyboard
  • Read data from the file
  • Write data to the file
  • Using DecimalFormat to format the decimal numbers
  • Using user-defined functions
  • Review how to write the code of data type: data members, constructor, mutator methods, accessor methods and toString method
  • How to declare an object of a class in main and how to access member of class by using the object
  • how to declare an array and how to initial values of the array elements and how to access each element of an array

REQUIREMENT

Provide the pseudo-code and the Java code for the application named SaleComparison_yourLastName.java

Suppose a store sales a product that is in either model X310 or model X410. At the end of each year, the store has the report named Model_X_Sale_yyyy.txt where yyyy is 4 digits of the year, for example, Model_X_Sale_2014.txt or Model_X_Sale_2013.txt, etc. The format of input file should be:

For example: Year 2013 the store has file Model_X_Sale_2013.txt as follows:

Jan 2777 1.99 3223 2.19
Feb 2431 1.99 2612 2.19
Mar 2540 1.99 2729 2.19
Apr 2557 2.19 2892 2.29
May 2515 2.19 2249 2.29
Jun 2639 2.19 3190 2.29
Jul 2610 1.89 2839 2.09
Aug 2595 1.89 2875 2.09
Sep 2456 1.89 2828 2.09
Oct 2454 1.99 2803 2.19
Nov 2707 1.99 3295 2.19
Dec 2893 1.99 3522 2.19

For example: Year 2014 the store has file Model_X_Sale_2014.txt as follows:

Jan 3128 1.59 3421 1.79
Feb 3130 1.59 2822 1.79
Mar 3126 1.59 3210 1.79
Apr 3075 1.69 3143 1.79
May 3250 1.69 2538 1.79
Jun 3133 1.69 3458 1.79
Jul 3211 1.79 3135 1.89
Aug 2958 1.79 3620 1.89
Sep 2823 1.79 3714 1.89
Oct 2989 1.89 3689 1.992
Nov 3088 1.89 4163 1.99
Dec 2906 1.89 4314 1.99

Where each line has 5 information of month, X310 units sold, X310 unit price, X410 units sold, and X410 unit price.

These files are saved in the storage

This project asks you to provide the pseudo-code and the Java code for the application that processes two tasks:

  • Summary Sale in one year
  • Sale Comparison between two years

The application continue allows users to use the program until they want to exit

Task 1 Summary Sale in one year

For each year, calculate the money sold of each product type in each month and the total money sold of each product type in whole year then display in the following format on screen and also write to the output file named SaleSummary_yourLastName_yyyy.txt where yyyy is 4 digits of the year For example: the output of the summary of sale in year 2013 and the output of the summary of sale in year 2014 See image.

Task 2

This task is to compare the sale on each product type between two years by calculate the different between number of product units sold between two years then calculate the % increase. The result should be displayed on the screen and write to the output file named SaleComparison_yourLastName_ xxxx_and_yyyy.txt as follows: See image.

HOW TO DO THE PROJECT

Create the project named FA2015PROJECT_LastName then add the following classes

*Define a data type class named as FA2015PROJECT_LastName_SaleInMonth.java that contains:

  • data members: month as a string, X310_Units as an int, X310_uPrice as a double, X410_Units as an int, X410_uPrice as a double
  • The constructor of the class FA2015PROJECT_LastName_SaleInMonth will accept a String then split it into the information of month, X310_Units, X310_uPrice, X410_Units and X410_uPrice
  • The assessor methods
  • The method to calculate the money sold X310 in the month: X310_Units * X310_uPrice
  • The method to calculate the money sold X410 in the month: X410_Units * X410_uPrice
  • The method to calculate total money sold both models = money sold X310 + money sold X410
  • The method to display on the screen the money sold in month on one line and in a column width of 15
  • The method to write to the output file the money sold in month on one line and in a column width of 15.

The format of the output in output file and on the screen is:

MonthmoneySoldX310 moneySoldX410

For example:

Jan 5526.23 7058.37
……

*Define a controlling class (a driver class) named FA2015PROJECT_LastName_SaleReport.java with the method main() that do the following:

Display the menu to allow users to choose the tasks:

  • Summary Of Sale In One Year
  • Compare Sales Between Two Years

Read the selected task to determine which task is processed; only terminate the program when users select EXIT

TASK 1:

Create a method for the task 1 to do the following:

  • Asks users to enter 4 digits for the year in yyyy format, then open the input file Model_T_Sale_yyyy.txt.
  • When reading the input file, for each line, create the object of the class FA2015PROJECT_LastName_SaleInMonth to pass the line in. Inside the constructor, the line will be splitted out into the information of month, X310_Units, X310_uPrice, X410_Units and X410_uPrice.
  • Use the object to access information or call methods from the class FA2015PROJECT_LastName_SaleInMonth to calculate or display output.
  • Handle to display on the screen the output as requested
  • Also, write the same output to the output file
  • Using System.out.printf(%15s, aString) to display aString on the right of the column (width = 15)
  • Using System.out.printf(%15.2f, aDecimalNumber) to display a decimal number with 2 decimal digits in column (width = 15)
  • Using System.out.printf(%n) to go to next line
  • Review to open file to read by using Scanner object
  • Review to open file to write by using PrintWriter object
  • Formula:
TOTAL: all the values in columns are added
Total sale in year: TOTAL of X310_SALE + TOTAL of X410_SALE

TASK2

Create a method for the task 2 to do the following:

  • Asks user to enter 4 digits of 2 years to compare in the format xxxx yyyy
  • Open 2 input files, Model_X_Sale_xxxx.txt and Model_X_Sale_yyyy.txt. (You should create these input files by typing the information to notepad and save with the above names) Two input files should be read parallel line by line such that for each line in each file, create the object of FA2015PROJECT_LastName_SaleInMonth to pass the line into the constructor. In the constructor of FA2015PROJECT_LastName_SaleInMonth the line will be splitted out into 5 information (see the instruction of class FA2015PROJECT_LastName_SaleInMonth above) Use the object to access the information and calculate the different between number of X310 units and number of X410 units and also calculate the % increase. (see the output displayed for task 2 above)
  • Columns X310_2013 and X310_2014 include the number of unit sold in year 2013 and 2014
  • Column INCREASE: is calculated by: number of units sold in 2014 number of units sold in 2013 INCREASE = X310_2014 X310_2013 (number of units sold in 2014 number of units sold in 2013)
  • Column % INCREASE is calculated by: INCREASE / number of units sold in 2013 %INCREASE = (double) INCREASE / (double) X310_2013 (INCREASE / number of units sold in 2013)
  • TOTAL: In the second and third columns are the sum of number of units sold in 12 months the year In the fourth column is the different of the total number of X410 units in the year and the total number of X310 units in the year In the fifth column is calculated as below:
% INCREASE = total of INCREASE / total of number of X310 units sold in the year (second column)
  • *The information of the table of SALE X410 COMPARISON is calculated as the same as for X310
  • It is easy to print out the output as requested, when you read each line in each input file, calculate the INCREASE and %INCREASE then save month, the number of X310 units sold in month of the first year, the number of X310 units sold in the second year, montly INCREASE and monthly % INCREASE, you should save them into 5 arrays with the same size and pass these arrays with all the totals to a different method to print them out

Create a method that prints out the result in the requested format.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.