Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROGRAM INSTRUCTIONS: There will be 3 classes in a project folder that generates sales reports for each sales rep, writes the sales reports to a

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

PROGRAM INSTRUCTIONS: There will be 3 classes in a project folder that generates sales reports for each sales rep, writes the sales reports to a file, and checks that the reports (as records) have been written. Don't forget to exit at the end of main(). The prompts and the final output in the sample output show you the logical progression of your code, and along with the instructions in the UML give you an idea as to where to place your code. 1. Work and submit this PA in a group. 2. UML Diagrams for the classes: Data members are variables. The variables are derived from the prompts and/or the final output. DO NOT code the methods in any way other than what is instructed. The - sign means private, the + means public, and underlines mean static in the UML. Class Name Sa1esReport This class is being given to you as it wi 77 be used to type the array in the Sa7essystem class. You are not a77owed to post this program anywhere per the UTSA HOnor code. 1. You wil1 insert comments for a. the program purpose, b. import statement purpose, c. each field's purpose, d. each method's purpose (comment boxes above the method headers). Expect to be tested on the final exam regarding code behavior in the methods of this class for chapters 9 and 11. 2. You wi11 insert code for missing Java statements. 3. Read the instructions in the first comment box on how to locate the lines requiring your attention. (C) 2022 Linda Shepherd 1. Call start() from SalesSystem. 2. Exit statement. 1. Chapter 7 , lesson 4 will help with Arrays of Objects. 2. Chapter 7 , lesson 6 will help with ArrayList. 3. The set, get, calculate and other methods mentioned here are from the SalesReport class. 4. Code local variables. a. Assign to aSalesReport this string formatted with 2 line advances at the beginning: "TANDEM ENTERPRISES". 5. Call setProjectedSales(). 6. Call setNoSalesReps(). 7. Finish creating the SalesReport array. 8. In a for loop with i as the loop-control variable: a. Re-initialize qrtCounter to 1 . b. At the current array location i. create a SalesReport object. ii. call setSalesRep() by sending it the sum of i+1; iii. call setNoQtrs(); iv. while qrtCounter is less than or equal to the call of getNoQtrs() 1) Re-initialize monthCounter to 1 . 2) Call chooseQtr() by sending it qrtCounter. 3) while monthCounter is less than or equal to the call of getNoMonths() a) Call determineMonthNo() by sending it monthCounter. b) Call setSalesRevenue(). c) Call calculateQtrlySales(). d) Pre-increment monthCounter. 4) Pre-increment qtrCounter. v. Call calculateAnnualSales(). vi. Add to aSalesReport the call to getSalesRepRevReport(). vii. Add to aSalesReport the call to getRepTargetMsg(). viii. add() to the ArrayList salesReports, aSalesReport. 2022 Linda Shepherd 4 ix. Re-initialize aSalesReport to the a String literal formatted with 2 line advances at the beginning: "TANDEM ENTERPRISES". 9. In an enhanced for-loop assign each String object from salesReports to eachReport. a. Print eachReport in a printf() using "\%s". 10. Call getCompanyTargetMsg() using the non-array object for SalesReport. 2. In a try block a. This prompt is coded with no line advances other than the one at the beginning. Enter saleskeports. txt as the name of the file. Enter the file name for sales report (WARNING: This will erase a pre-existing file!): b. Open the file in PrintWriter. c. Use a for-loop to get the data from the array into the record variable using these format specifiers: "\%s, \%d, \%s, \%.2f\%n" in the order of the get methods for the date, number of quarters, sales rep, and quarterly sales. i. Write the record to the file using printf(). 3. In a catch block that catches an IOException into e a. Use the err object from System to call printf() by sending it this message: File cannot be created. b. Re-initialize fileError to true. 4. Using a single-selection if, test for there is no fileError. a. Close the outputFile. b. Print the message: Data written to the xxxxxxxxxx file. where the x's is the name of the file. 1. Code local variables. 2. In a try block a. Enter SalesReports .txt as the name of the file for this prompt. Enter the name for the sales report file: b. Finish creating the File object with fileName. c. Finish creating the Scanner object with file. d. Use a while-loop by testing inputFile.hasNext() to i. read the next line from the inputFile into fileRecord. (c) 2022 Linda Shepherd 5 ii. print what was just read. Use a format specifier with a line advance at the beginning. e. Print a blank line using println(). 3. In a catch block that catches IOException into e a. Use the err object from System to call printf() by sending it this message: File not found! 4. In a catch block that catches NullPointerException into e a. Use the err object from System to call printf() by sending it this message: Record couldn't be accessed or read. 5. Using a single-selection if, test for there is no fileNotFound. a. Close the inputFile. +exitmessage(): void 1. Print: Exiting Sales system. 3. Use printf() with format specifiers where needed. 4. The prompts, the final output specs, and the sample output show you in what order to place your code. To return from these links press Alt then left arrow. 5. You are to generate output from your program according the instructions in the sample output section. 6. Make sure your code is properly indented. 7. Commenting Your Program: Refer to the Java Style Guide posted in for more commenting and formatting details. a. In your program, YOU MUST insert a program purpose in the first comment box. The content of that first comment box was shown to you in the Anatomy of a Java Program lecture for chapter 1. b. Use Javadoc comment boxes beginning with / and ending with / for your comment boxes. c. Insert a Javadoc comment box above your methods explaining what is going on in the method that goes for the main() which is a method. d. Line comment the import statements and the variables declared at the class level and/or in any method [including main()], and close braces. 8. Formatting Rules: Always test to validate your program is functioning properly with the correct output and spacing (line advances and spacing after punctuation). The \%n can function differently when using separate printf statements versus one printf. SALES REP OUTPUT SPECIFICATIONS: The Zs and 9s represent the output as formatted numbers. Zs indicate zero-suppression of leading numbers. 9s represent numbers printed as digits from 0-9. Xs are text. Zs, 9s, Xs are values that will change, everything else are headers, titles, and ( 2022 Linda Shepherd 6 labels. Use System.out.printf() and the appropriate format specifiers to properly format the output. The year is NOT to be hard coded into the header, instead, you will capture the system's date and format for the year only (refer to Appendix I). This is so the year corresponds to when the program is run. What is printed is for each sales rep. KHeader (Title). Triple line advance uses 2%n s with 2nd and 3rd lines of the header using 1%n. TANDEM ENTERPRISES TOC SALES REVENUE FOR 9 QUARTER(S) OF 9999 SALES REP: XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX labels. Use System.out.printf() and the appropriate format specifiers to properly format the output. The year is NOT to be hard coded into the header, instead, you will capture the system's date and format for the year only (refer to Appendix I). This is so the year corresponds to when the program is run. What is printed is for each sales rep. KHeader (Title). Triple line advance uses 2%n s with 2nd and 3rd lines of the header using 1%n. SALES REP: Xxxxxxxxxxxx Xxxxxxxxxxxxxxxxxxxx \begin{tabular}{ll|l|} Total Year-To-Date: $ZZZ,ZZZ,ZZ9.99 & Total Label with year-to-date sales figure which tells you your output variable. When printed, the $ sign will not float to the leading digit. \\ \cline { 3 - 4 } & & \end{tabular} FINAL OUTPUT SPECIFICATIONS: Printed after the last sales rep. CORPORATE SALES PERFORMANCE It's been a GOOD year so far. There could be a year-end bonus of about 2-5\% if we can keep on top of our sales goals. Thank you all and please continue your excellent effort! OR Sales are lagging projections. A year-end bonus may not be possible. PROGRAM INSTRUCTIONS: There will be 3 classes in a project folder that generates sales reports for each sales rep, writes the sales reports to a file, and checks that the reports (as records) have been written. Don't forget to exit at the end of main(). The prompts and the final output in the sample output show you the logical progression of your code, and along with the instructions in the UML give you an idea as to where to place your code. 1. Work and submit this PA in a group. 2. UML Diagrams for the classes: Data members are variables. The variables are derived from the prompts and/or the final output. DO NOT code the methods in any way other than what is instructed. The - sign means private, the + means public, and underlines mean static in the UML. Class Name Sa1esReport This class is being given to you as it wi 77 be used to type the array in the Sa7essystem class. You are not a77owed to post this program anywhere per the UTSA HOnor code. 1. You wil1 insert comments for a. the program purpose, b. import statement purpose, c. each field's purpose, d. each method's purpose (comment boxes above the method headers). Expect to be tested on the final exam regarding code behavior in the methods of this class for chapters 9 and 11. 2. You wi11 insert code for missing Java statements. 3. Read the instructions in the first comment box on how to locate the lines requiring your attention. (C) 2022 Linda Shepherd 1. Call start() from SalesSystem. 2. Exit statement. 1. Chapter 7 , lesson 4 will help with Arrays of Objects. 2. Chapter 7 , lesson 6 will help with ArrayList. 3. The set, get, calculate and other methods mentioned here are from the SalesReport class. 4. Code local variables. a. Assign to aSalesReport this string formatted with 2 line advances at the beginning: "TANDEM ENTERPRISES". 5. Call setProjectedSales(). 6. Call setNoSalesReps(). 7. Finish creating the SalesReport array. 8. In a for loop with i as the loop-control variable: a. Re-initialize qrtCounter to 1 . b. At the current array location i. create a SalesReport object. ii. call setSalesRep() by sending it the sum of i+1; iii. call setNoQtrs(); iv. while qrtCounter is less than or equal to the call of getNoQtrs() 1) Re-initialize monthCounter to 1 . 2) Call chooseQtr() by sending it qrtCounter. 3) while monthCounter is less than or equal to the call of getNoMonths() a) Call determineMonthNo() by sending it monthCounter. b) Call setSalesRevenue(). c) Call calculateQtrlySales(). d) Pre-increment monthCounter. 4) Pre-increment qtrCounter. v. Call calculateAnnualSales(). vi. Add to aSalesReport the call to getSalesRepRevReport(). vii. Add to aSalesReport the call to getRepTargetMsg(). viii. add() to the ArrayList salesReports, aSalesReport. 2022 Linda Shepherd 4 ix. Re-initialize aSalesReport to the a String literal formatted with 2 line advances at the beginning: "TANDEM ENTERPRISES". 9. In an enhanced for-loop assign each String object from salesReports to eachReport. a. Print eachReport in a printf() using "\%s". 10. Call getCompanyTargetMsg() using the non-array object for SalesReport. 2. In a try block a. This prompt is coded with no line advances other than the one at the beginning. Enter saleskeports. txt as the name of the file. Enter the file name for sales report (WARNING: This will erase a pre-existing file!): b. Open the file in PrintWriter. c. Use a for-loop to get the data from the array into the record variable using these format specifiers: "\%s, \%d, \%s, \%.2f\%n" in the order of the get methods for the date, number of quarters, sales rep, and quarterly sales. i. Write the record to the file using printf(). 3. In a catch block that catches an IOException into e a. Use the err object from System to call printf() by sending it this message: File cannot be created. b. Re-initialize fileError to true. 4. Using a single-selection if, test for there is no fileError. a. Close the outputFile. b. Print the message: Data written to the xxxxxxxxxx file. where the x's is the name of the file. 1. Code local variables. 2. In a try block a. Enter SalesReports .txt as the name of the file for this prompt. Enter the name for the sales report file: b. Finish creating the File object with fileName. c. Finish creating the Scanner object with file. d. Use a while-loop by testing inputFile.hasNext() to i. read the next line from the inputFile into fileRecord. (c) 2022 Linda Shepherd 5 ii. print what was just read. Use a format specifier with a line advance at the beginning. e. Print a blank line using println(). 3. In a catch block that catches IOException into e a. Use the err object from System to call printf() by sending it this message: File not found! 4. In a catch block that catches NullPointerException into e a. Use the err object from System to call printf() by sending it this message: Record couldn't be accessed or read. 5. Using a single-selection if, test for there is no fileNotFound. a. Close the inputFile. +exitmessage(): void 1. Print: Exiting Sales system. 3. Use printf() with format specifiers where needed. 4. The prompts, the final output specs, and the sample output show you in what order to place your code. To return from these links press Alt then left arrow. 5. You are to generate output from your program according the instructions in the sample output section. 6. Make sure your code is properly indented. 7. Commenting Your Program: Refer to the Java Style Guide posted in for more commenting and formatting details. a. In your program, YOU MUST insert a program purpose in the first comment box. The content of that first comment box was shown to you in the Anatomy of a Java Program lecture for chapter 1. b. Use Javadoc comment boxes beginning with / and ending with / for your comment boxes. c. Insert a Javadoc comment box above your methods explaining what is going on in the method that goes for the main() which is a method. d. Line comment the import statements and the variables declared at the class level and/or in any method [including main()], and close braces. 8. Formatting Rules: Always test to validate your program is functioning properly with the correct output and spacing (line advances and spacing after punctuation). The \%n can function differently when using separate printf statements versus one printf. SALES REP OUTPUT SPECIFICATIONS: The Zs and 9s represent the output as formatted numbers. Zs indicate zero-suppression of leading numbers. 9s represent numbers printed as digits from 0-9. Xs are text. Zs, 9s, Xs are values that will change, everything else are headers, titles, and ( 2022 Linda Shepherd 6 labels. Use System.out.printf() and the appropriate format specifiers to properly format the output. The year is NOT to be hard coded into the header, instead, you will capture the system's date and format for the year only (refer to Appendix I). This is so the year corresponds to when the program is run. What is printed is for each sales rep. KHeader (Title). Triple line advance uses 2%n s with 2nd and 3rd lines of the header using 1%n. TANDEM ENTERPRISES TOC SALES REVENUE FOR 9 QUARTER(S) OF 9999 SALES REP: XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX labels. Use System.out.printf() and the appropriate format specifiers to properly format the output. The year is NOT to be hard coded into the header, instead, you will capture the system's date and format for the year only (refer to Appendix I). This is so the year corresponds to when the program is run. What is printed is for each sales rep. KHeader (Title). Triple line advance uses 2%n s with 2nd and 3rd lines of the header using 1%n. SALES REP: Xxxxxxxxxxxx Xxxxxxxxxxxxxxxxxxxx \begin{tabular}{ll|l|} Total Year-To-Date: $ZZZ,ZZZ,ZZ9.99 & Total Label with year-to-date sales figure which tells you your output variable. When printed, the $ sign will not float to the leading digit. \\ \cline { 3 - 4 } & & \end{tabular} FINAL OUTPUT SPECIFICATIONS: Printed after the last sales rep. CORPORATE SALES PERFORMANCE It's been a GOOD year so far. There could be a year-end bonus of about 2-5\% if we can keep on top of our sales goals. Thank you all and please continue your excellent effort! OR Sales are lagging projections. A year-end bonus may not be possible

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Management And Cost Accounting

Authors: Charles T. Horngren (Author), Alnoor Bhimani (Author), Srikant M. Datar (Author), George Foster

2nd Edition

0273651838, 978-0273651833

More Books

Students also viewed these Accounting questions