In this project you will work on a program that will help visualize a bar graph...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In this project you will work on a program that will help visualize a bar graph chart of Air Quality Health Index [1] data, collected, and entered by user. • There are three classes provided for starter code: Program with method main User with methods for user inputs AirQualityHealthIndexRecord with methods, enterData, printReport, resetData • The program you create must use a 10-element array of int, loops, a basic menu system and be object oriented. • Most of the program functionality is completed for you, you will need to provide programmer comments as indicated and expected, as well as author method main, and method printReport. A detailed UML class diagram is provided to overview the classes: -keyboard:Scanner -User() +inputinteger() int +inputinteger(prompt:String): int +inputDouble():double +inputDouble(prompt:String):double +inputString():String +inputString(message:String): String +inputinteger(prompt:String, min:int, max:int):int User AirQualityhealthIndexRecorder -AQHI_MAX:int -values:int[] +AirQualityhealthIndexRecorder() +enterData():void +printReport():void +resetData():void Program +main(args:String[]):void UML Class Diagram by Amir Rad Task 1 - Menu system in method main Use pseudocode and a flowchart to design a menu system within method main. - Class User should be used for all user input - Delegate processing from the menu to the methods of class AirQualityHealthIndexRecorder as needed. Use the constants provided with a case structure inside of a do-while loop, exiting the loop when the user enters the number 4 i.e., EXIT_PROGRAM. - Refer to the Menu System handouts from Weeks 9 and 10 for help. - Examine the starter code for class Program for the full list of constants. The menu displayed on screen would look similar to: 1 Enter AQHI Values 2 Display Report 3 Reset AQHI Data 4 Exit Program Provide the pseudocode and flowchart in a MS Word document. Task 2 printReport method Use pseudocode and a flowchart to design this method. Starter logic (hints) for the method are: Use a loop to traverse the array from index zero, to max index. Output the AQHI values as a line label then; Use another loop that starts at 1 and ends at the value in the indexed element of the array; 5 6 7 8* 9 10 Print* characters, one at a time, using the inner loop; Output a new-line before resuming the outer loop. Sample output from this method would look like: 1 ********** 2 3 4** The array had a value of 10 in index zero, a value of 2 in index 3, and a value of 1 in index 7, suggesting a good air condition. Code this method in Java, using your pseudocode and flowchart as a guide. Tip: To pad spaces to the left of the numbers in the report above, use %3d, the 3 means output should be 3 characters wide, padding spaces as needed to the left of the numbers. e.g. System.out.printf("%3d", (index + 1)); //index is loop counter e.g. 0 and bumped to 1 only for output. Provide the pseudocode and flowchart in a MS Word document. Task 3 - Trace Table See the first Week 10 lecture slide set, slide numbers 15 and 19 with regards to using a trace table to test loop logic. Create a trace table that tests the nested loops inside of your printReport method based on your student number. Suggestion: Set a break point on the outer-loop of the printReport method. Then run the program with debugging and enter the numbers of your student number, excluding any zeros as these would not be accepted by the program. For example, a fictious student number like 080654311 would be entered into the program as separate numbers: 8654311 (one number per input loop). Then print the report from the menu which will enter the break perspective. You can use the variables window, and step-into each line in the loop (step over API calls) and record the changes in the loop counter variables, and record the program output. Each row in the trace table would be for an iteration of each loop, row by row. The table below is an example you can use as an example format; however, you will need to update the trace table based on your student number. Also include your student number next to your table. The variable names used in the table are index, for the outer loop, and count for the inner loop. The table below uses the fictional student number above. index 0 0 1 2 2 Enter loop? yes In loop ves In loop yes In loop Action(s) output index +1 output output index + output output index +1 output count Enter loop? 2 3 1 1 2 yes yes no no yes Action(s) output output none none output **" none Notes output label as 1 just before inner loop output *, values[index] has 2 output a, * values[index] has 2 Loop should exit output a new-line output label as 2 just before inner loop values[index] has zero, so do not loop output a new-line output label as 3 just before inner loop output, values[index] has 1 Loop should exit output a new-line And so on.. Task 4-Screen Shot Run the program and use the menu system to enter some AQHI values, using your student number as above, then use the display report menu option. The screen shot test values should follow from your student number, minus zeros as instructed above. Task 5-Memory Map • Set a breakpoint within your printReport method, then run your program with debugging. • Enter each digit of your student number, excepting zero, as data for the array in order from left to right as has been instructed above. • Attempt to display the report using the menu, which will then enter debug mode. • Draw a memory map starting from the variable for the array to the array itself, you can use Diagrams.net or this can be done by hand (write clearly), photographed with a cell phone and emailed to yourself so you can place it into your MS Word document. • See Hybrids 09 and 10 for guidance here. Task 6-Method-Call-Stack and Heap-Memory-Area Answer the following questions in your MS Word document as simply stack or heap. (See Hybrid 07 to help with answering these questions.) • Is the variable for the array allocated on the call-stack or the heap-memory i.e. int[] values? • Is the array object itself allocated on the call-stack or heap-memory i.e. new int[AQHI_MAX]? • Are the constants declared and used inside method main allocated onto the stack or heap memory area? Appendix - Sample Program Run • Numbers were selected at random for this program run, it is not based on a student number. 1 Enter AQHI Values 2 Display Report 3 Reset AQHI Data 4 Exit Program Select option: 1 Enter AQHI value: 8 Enter another? (y/n): y Enter AQHI value: 8 Enter another? (y/n): y Enter AQHI value: 8 Enter another? (y/n): y Enter AQHI value: 8 Enter another? (y/n): y Enter AQHI value: 7 Enter another? (y/n): y Enter AQHI value: 7 Enter another? (y/n): y Enter AQHI value: 7 Enter another? (y/n): y Enter AQHI value: 6 Enter another? (y/n): y Enter AQHI value: 5 Enter another? (y/n): y Enter AQHI value: 4 Enter another? (y/n): y Enter AQHI value: 4 Enter another? (y/n): y Enter AQHI value: 3 Enter another? (y/n): y Enter AQHI value: 2 Enter another? (y/n): y Enter AQHI value: 1 Enter another? (y/n): y Enter AQHI value: 1 Enter another? (y/n): n 1 Enter AQHI Values 2 Display Report 3 Reset AQHI Data 4 Exit Program Select option: 2 1 ** 2* 3* 4 ** 5* 6* 7*** 8 **** 9 10 1 Enter AQHI Values 2 Display Report 3 Reset AQHI Data 4 Exit Program Select option: 3 1 Enter AQHI Values 2 Display Report 3 Reset AQHI Data 4 Exit Program Select option: 2 1 2 3 4 5 6 7 8 9 10 1 Enter AQHI Values 2 Display Report In this project you will work on a program that will help visualize a bar graph chart of Air Quality Health Index [1] data, collected, and entered by user. • There are three classes provided for starter code: Program with method main User with methods for user inputs AirQualityHealthIndexRecord with methods, enterData, printReport, resetData • The program you create must use a 10-element array of int, loops, a basic menu system and be object oriented. • Most of the program functionality is completed for you, you will need to provide programmer comments as indicated and expected, as well as author method main, and method printReport. A detailed UML class diagram is provided to overview the classes: -keyboard:Scanner -User() +inputinteger() int +inputinteger(prompt:String): int +inputDouble():double +inputDouble(prompt:String):double +inputString():String +inputString(message:String): String +inputinteger(prompt:String, min:int, max:int):int User AirQualityhealthIndexRecorder -AQHI_MAX:int -values:int[] +AirQualityhealthIndexRecorder() +enterData():void +printReport():void +resetData():void Program +main(args:String[]):void UML Class Diagram by Amir Rad Task 1 - Menu system in method main Use pseudocode and a flowchart to design a menu system within method main. - Class User should be used for all user input - Delegate processing from the menu to the methods of class AirQualityHealthIndexRecorder as needed. Use the constants provided with a case structure inside of a do-while loop, exiting the loop when the user enters the number 4 i.e., EXIT_PROGRAM. - Refer to the Menu System handouts from Weeks 9 and 10 for help. - Examine the starter code for class Program for the full list of constants. The menu displayed on screen would look similar to: 1 Enter AQHI Values 2 Display Report 3 Reset AQHI Data 4 Exit Program Provide the pseudocode and flowchart in a MS Word document. Task 2 printReport method Use pseudocode and a flowchart to design this method. Starter logic (hints) for the method are: Use a loop to traverse the array from index zero, to max index. Output the AQHI values as a line label then; Use another loop that starts at 1 and ends at the value in the indexed element of the array; 5 6 7 8* 9 10 Print* characters, one at a time, using the inner loop; Output a new-line before resuming the outer loop. Sample output from this method would look like: 1 ********** 2 3 4** The array had a value of 10 in index zero, a value of 2 in index 3, and a value of 1 in index 7, suggesting a good air condition. Code this method in Java, using your pseudocode and flowchart as a guide. Tip: To pad spaces to the left of the numbers in the report above, use %3d, the 3 means output should be 3 characters wide, padding spaces as needed to the left of the numbers. e.g. System.out.printf("%3d", (index + 1)); //index is loop counter e.g. 0 and bumped to 1 only for output. Provide the pseudocode and flowchart in a MS Word document. Task 3 - Trace Table See the first Week 10 lecture slide set, slide numbers 15 and 19 with regards to using a trace table to test loop logic. Create a trace table that tests the nested loops inside of your printReport method based on your student number. Suggestion: Set a break point on the outer-loop of the printReport method. Then run the program with debugging and enter the numbers of your student number, excluding any zeros as these would not be accepted by the program. For example, a fictious student number like 080654311 would be entered into the program as separate numbers: 8654311 (one number per input loop). Then print the report from the menu which will enter the break perspective. You can use the variables window, and step-into each line in the loop (step over API calls) and record the changes in the loop counter variables, and record the program output. Each row in the trace table would be for an iteration of each loop, row by row. The table below is an example you can use as an example format; however, you will need to update the trace table based on your student number. Also include your student number next to your table. The variable names used in the table are index, for the outer loop, and count for the inner loop. The table below uses the fictional student number above. index 0 0 1 2 2 Enter loop? yes In loop ves In loop yes In loop Action(s) output index +1 output output index + output output index +1 output count Enter loop? 2 3 1 1 2 yes yes no no yes Action(s) output output none none output **" none Notes output label as 1 just before inner loop output *, values[index] has 2 output a, * values[index] has 2 Loop should exit output a new-line output label as 2 just before inner loop values[index] has zero, so do not loop output a new-line output label as 3 just before inner loop output, values[index] has 1 Loop should exit output a new-line And so on.. Task 4-Screen Shot Run the program and use the menu system to enter some AQHI values, using your student number as above, then use the display report menu option. The screen shot test values should follow from your student number, minus zeros as instructed above. Task 5-Memory Map • Set a breakpoint within your printReport method, then run your program with debugging. • Enter each digit of your student number, excepting zero, as data for the array in order from left to right as has been instructed above. • Attempt to display the report using the menu, which will then enter debug mode. • Draw a memory map starting from the variable for the array to the array itself, you can use Diagrams.net or this can be done by hand (write clearly), photographed with a cell phone and emailed to yourself so you can place it into your MS Word document. • See Hybrids 09 and 10 for guidance here. Task 6-Method-Call-Stack and Heap-Memory-Area Answer the following questions in your MS Word document as simply stack or heap. (See Hybrid 07 to help with answering these questions.) • Is the variable for the array allocated on the call-stack or the heap-memory i.e. int[] values? • Is the array object itself allocated on the call-stack or heap-memory i.e. new int[AQHI_MAX]? • Are the constants declared and used inside method main allocated onto the stack or heap memory area? Appendix - Sample Program Run • Numbers were selected at random for this program run, it is not based on a student number. 1 Enter AQHI Values 2 Display Report 3 Reset AQHI Data 4 Exit Program Select option: 1 Enter AQHI value: 8 Enter another? (y/n): y Enter AQHI value: 8 Enter another? (y/n): y Enter AQHI value: 8 Enter another? (y/n): y Enter AQHI value: 8 Enter another? (y/n): y Enter AQHI value: 7 Enter another? (y/n): y Enter AQHI value: 7 Enter another? (y/n): y Enter AQHI value: 7 Enter another? (y/n): y Enter AQHI value: 6 Enter another? (y/n): y Enter AQHI value: 5 Enter another? (y/n): y Enter AQHI value: 4 Enter another? (y/n): y Enter AQHI value: 4 Enter another? (y/n): y Enter AQHI value: 3 Enter another? (y/n): y Enter AQHI value: 2 Enter another? (y/n): y Enter AQHI value: 1 Enter another? (y/n): y Enter AQHI value: 1 Enter another? (y/n): n 1 Enter AQHI Values 2 Display Report 3 Reset AQHI Data 4 Exit Program Select option: 2 1 ** 2* 3* 4 ** 5* 6* 7*** 8 **** 9 10 1 Enter AQHI Values 2 Display Report 3 Reset AQHI Data 4 Exit Program Select option: 3 1 Enter AQHI Values 2 Display Report 3 Reset AQHI Data 4 Exit Program Select option: 2 1 2 3 4 5 6 7 8 9 10 1 Enter AQHI Values 2 Display Report
Expert Answer:
Answer rating: 100% (QA)
The project aims to develop a Java program for visualizing a bar graph of Air Quality Health Index AQHI data entered by the user The program utilizes ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
You will have three separate, or internal classes that will: Instantiate a Card Instantiate a Deck of those Cards, and shuffle and deal them. Play the game. In this project you will simulate the...
-
For this lab, you will work on a simple GUI application. The starting point for your work consists of four files (TextCollage, DrawTextItem, DrawTextPanel, and SimpleFileChooser) in the code...
-
Lab 10: ArrayLists and Files in a GUI Application For this lab, you will work on a simple GUI application. The starting point for your work consists of four files (TextCollage, DrawTextItem,...
-
Figure shows an overhead view of a ring that can rotate about its center like a merry-go-round. Its outer radius R2 is 0.800 m, its inner radius R1 is R2/2.00, its mass M is 8.00 kg, and the mass of...
-
How could you convert butanoic acid into the following compounds? Write each step showing the reagents needed. (a) 1 -Butanol (b) 1Bromobutane (c) Pentanoic acid (d) 1-Butenc (e) Octane
-
Which of the following alkyl halides could be successfully used to form a Grignard reagent? a. HOCH2CH2CH2CH2Br b. c. d. H2NCH2CH2CH2Br BrCH2CH CH COH CH3NCH2CH2CH,Br CH3
-
A \(5-\mathrm{kg}\) object is subject to an interaction that has a potential energy \(U(x)=\frac{1}{2} k x^{2}-b x\), where \(k=2.0 \mathrm{~J} / \mathrm{m}^{2}\) and \(b=1.5 \mathrm{~J} /...
-
Figurate Industries has 750,000 shares of cumulative preferred stock outstanding. It has passed the last three quarterly dividends of $2.50 per share and now (at the end of the current quarter)...
-
(a) The following information is given for 3 companies that are identical except for their capital structure: Orange Grape Apple Total invested capital 1,00,000 1,00,000 1,00,000 Debt/assets ratio...
-
Kenmare Architects Ltd. (KAL) was incorporated and commenced operations on January 1, 2014. Sheila Kenmare, the company's only employee, consults with various clients and uses expensive equipment to...
-
The WACC is used as the discount rate to evaluate various capital budgeting projects. However, it is important to realize that the WACC is only an appropriate discount rate for a project of average...
-
Cultivation Theory is a critical theory and demands action from its adherents. Do you believe researchers and theorists should become politically active in the fields they study? Why or why not?
-
Discuss what canon of rhetoric is most important when politicians speak to their constituents. Use examples to defend your view.
-
Discuss a situation in which accommodation might backfire on an individual.
-
Do you agree with Condit that Burkes theory is culture specific rather than universal? Explain your answer.
-
Do you agree or disagree with McLuhan regarding television being a cool medium? Use examples to defend your view.
-
Which of the following statements concerning property insuranceis (are) correct? 1. Broad named perilpolicies cover all losses to covered property unless the loss isspecifically excluded. 2....
-
In Exercises 1558, find each product. (9 - 5x) 2
-
Alexis owns 100% of the shares of Ruby. During 2013, the following events occurred: 1. Alexis sold inventory for $10,000 that had been sold to it by Ruby in December 2012. The inventory originally...
-
Why are associates distinguished from other investments held by the investor?
-
On January 1, 2013, New Ltd. acquired the following assets and liabilities from Daylight Ltd.: In exchange for these assets and liabilities, New issued 100,000 shares that had been issued for $1.20...
-
The population of unemployed adults has ages with mean m and standard deviations. Samples of unemployed adults are randomly selected so that there are exactly 100 in each sample. For each sample, the...
-
The percentage of heights less than 144 centimeters
-
In this section, it was noted that the standard deviation of sample means is s/1n. In that expression, what does s represent and what does n represent?
Study smarter with the SolutionInn App