Transcribed TextTranscribed Text

PROJECT 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: A store that sales a product that is in either model T224 or model T334. At the end of each year, the store has the report named Model_T_Sale_yyyy.txt where yyyy is 4 digits of the year, for example, Model_T_Sale_2016.txt or Model_T_Sale_2015.txt, etc. The format of input file should be: For example: Year 2015 the store has file Model_T_Sale_2015.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 2016 the store has file Model_T_Sale_2016.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.99 Nov 3088 1.89 4163 1.99 Dec 2906 1.89 4314 1.99 Where each line has 5 information of month, T224 units sold, T224 unit price, T334 units sold, and T334 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: 1. Summary Sale in one year 2. 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_ _yyyy.txt where yyyy is 4 digits of the year For example: the output of the summary of sale in year 2015 and the output of the summary of sale in year 2016 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. he result should be displayed on the screen and write to the output file named SaleComparison_ _ xxxx_and_yyyy.txt as follows: HOW TO DO THE PROJECT Create the project named _ then add the following classes *Draw UML and write the code of a data type class named as that contains: -data members: month as a string, T224_Units as an int, T224_uPrice as a double, T334_Units as an int, T334_uPrice as a double -The constructor of the class MonthlySale will accept a String then split it into the information of month, T224_Units, T224_uPrice, T334_Units and T334_uPrice -The assessor methods -The method to calculate the money sold T224 in the month: T224_Units * T224_uPrice -The method to calculate the money sold T334 in the month: T334_Units * T334_uPrice -The method to calculate total money sold both models = money sold T224 + money sold T334 -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: Month moneySoldT224 moneySoldT334 For example: Jan 5526.23 7058.37 …… *Write the pseudo-code or draw the flowchart of main() in the controlling class (a driver class) named with the method main() that do the following: -Display the menu to allow users to choose the tasks: 1. Summary Of Sale In One Year 2. 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 _MonthlySale_ to pass the line to the object. -Inside the constructor, the line will be splitted out into the information of month, T224_Units, T224_uPrice, T334_Units and T334_uPrice. -Use the object to access information or call methods from the class MonthlySale_ 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 String.format(“%15s”, aString) to create aString on the right of the column (width = 15) -Using String.format(“%15.2f”, aDecimalNumber) to create a decimal with 2 decimal digits in column (width = 15) -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 T224_SALE + TOTAL of T334_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_T_Sale_xxxx.txt and Model_T_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 __MontlySale to pass the line into the constructor. In the constructor of __MontlySale the line will be splitted out into 5 information (see the instruction of class __MontlySale above) Use the object to access the information and calculate the different between number of T224 units and number of T334 units and also calculate the % increase. (see the output displayed for task 2 above) -Columns T224_2013 and T224_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 = T224_2014 – T224_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) T224_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 T334 units in the year and the total number of T224 units in the year In the fifth column is calculated as below: % INCREASE = total of INCREASE / total of number of T224 units sold in the year (second column) *The information of the table of SALE T334 COMPARISON is calculated as the same as for T224 -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 T224 units sold in month of the first year, the number of T224 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.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.*;

public class SaleReport {
    public static void print(PrintWriter output) {
       print("", output);
    public static void print(String s, PrintWriter output) {
    * TASK 1
    public static void printYearlySummary(int year) {
       String fIn = "Model_T_Sale_"+year+".txt";
       String fOut = "Sale_Summary_"+year+".txt";
       File f = new File(fOut);
       if (f.exists()) {
       try(PrintWriter output = new PrintWriter(new FileWriter(fOut,true)))
            print(String.format("%42s","SUMMARY OF SALE IN YEAR "+year),output);
            print(String.format("%15s","MONTH")+String.format("%15s","T224 SALE")+String.format("%15s","T334 SALE"),output);
            double T224Total = 0.0;
            double T334Total = 0.0;
            try(BufferedReader br = new BufferedReader(new FileReader(fIn))) {
                for(String line; (line = br.readLine()) != null; ) {
                   MonthlySale sale = new MonthlySale(line);
                   T224Total += sale.getT224Sales();
                   T334Total +=
$80.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats