Project Overview

For this assignment you will be provided with incomplete sample starter code that you can modify and build upon. Your task will be to carry out the design, analysis, coding and testing to add several additional features to this sample code. You are expected to fully comment the provided code as well as your own code. The sample code provided has some minor issues that mean that although the code compiles it does not run as required.

Project Specification

The program that is to be developed should enable the entry of data from a short survey and to provide the user with some short reports on this data.

The data to be entered is from a survey and initially includes the following information:

  • Gender male, female, other or unspecified
  • Preferred hand left, right, both
  • Super power invisibility, super strength
  • Life preference famous, happy

The program should present the user with a menu that provides the following functionality:

  • Input data
  • View data
  • View report and graph
  • View basic statistics

Further details on functionality are provided in the task specifications provided below

Part A Code Comprehension

Your task is to first answer some questions testing your comprehension of the partial solution. Use the sample code provided in StarterCode.java to answer the following questions. Include the answers in your assignment submission.

1. The code provided does not contain any comments.

  • Briefly explain why comments are important in code.
  • Update the code provided to include comments include a copy of the commented code starter code in your assignment submission.

2. Identify all of the lines of code within the program that are associated with obtaining user input. This can be done by either copying the lines into your answers or highlighting the lines within the code.

3. The variable finished should be used as the condition for the while loop.

  • Briefly explain the purpose of the variable finished.
  • What value will it have when the while loop is initially entered?

4. Run the program. When the menu is presented enter 2 as the selected item.

  • What is the output of the program to the console? Why are all the values 0?
  • Briefly explain how would you should alter the code below so that it displays an appropriate prompt, rather than Enter Response 1 for each loop:
case 1: System.out.println("Menu selection 1");
for(int i=0;i System.out.println("Enter Response 1");

5. Identify the lines that would need to be altered so that the menu is controlled by a do-while loop rather than the whileloop and provide the new lines of code required

6. Currently a switch-statement is used within the program to handle the different menu options. What other program structure could have been used?

7. Run the program.

  • use the following table to test the code provided:
Menu Selection Expected Actual Notes
1 Displays "Menu selection 1" and prompts the user for the responses for gender Displays "Menu selection 1" As expected
2 Displays "Menu selection 2" and contents of the array for each student
3 Displays "Menu selection 3"
4 Displays "Menu selection 4"
5 Exits the program -1 Error -6 Error
  • Briefly outline the changes would you would need to make to the program so that it handles the menu entries correctly and exits the program when the user enters menu selection 4. Note: You do not need to make the changes in the code for Part A.

8. With the program an array has been used to store the data. Currently the code has two lines declaring the array, one that has been commented out.

  • Briefly explain both of the lines of code used to declare arrays
  • Briefly explain why the programmer would include the declaration that has been commented out.

Part B Program Analysis, Implementation and Development

It is suggested that you design, implement and test each of detailed below in order completing each section completely and correctly before proceeding to the next. For each stage, with the exception of stage 1, you should:

1. design a solution in the form of pseudo-code to carry out the required task - include this pseudo-code as part of your project documentation, clearly indicating which stage it belongs to;

2. perform a desk check of your logic - if you find any problems with your pseudo-code you should redesign and retest;

3. implement the stage update the code so that it implements the algorithm you have designed - at the end of each stage listed below save a copy of the code that has been developed and name each file appropriately;

4. test the stage ensure that before moving onto the next stage of development that the program works and that there are no logic or runtime errors

Development Stages

1. Update the code so that it:

  • includes at least two new super powers and two new life preferences;
  • includes at least 5 new responses in the test data that has been hard coded into the array;
  • exits the program when the user enters 4 for exit
  • handles case 2 appropriately (ie does not fall through to case 3); and
  • displays an error if the user enters an incorrect selection from the menu.

2. Update menu item 1 case so that:

  • the response number is displayed correctly when prompting the user to enter data this should start at 1;
  • the program prompts the user for the survey results to be entered for each respondent and stores the data into the correct positions within the array. For example:
Gender (1=Male 2=Female 3=Other 4=Unspecified) :
Left or right handed (1=Left 2=Right 3=Both):
Super power (1=Invisibility 2=Super strength 3=…):
Life preference (1=Famous 2=Happy 3=….):
Age (in years):

3. Update menu item 2 so that it displays all of the raw data that is stored in the array. For example:

Num Gender Lefty? Power Life Age
0 0 0 0 1 29
1 1 1 1 0 20 Etc..

4. Update menu item 3 -.display at least one graph using the data that has been entered. For example you might display a histogram of the genders or super powers. Within your documentation you should design and briefly explain why you have decided to design that particular graph.

5. Update menu item 4 so that it displays a short report on the results. In your documentation you should provide a design the report and a brief explanation of why your report has been designed that way. Your report must include at least the following:

  • The age of the oldest or youngest respondent(s)
  • The average age
  • The super power that was the most or least popular

6. Data validation add code to validate any data entered by the user. For example: for menu item 1 the data for gender should be validated so that only the values between 1 and 4) will be stored by the program; if an invalid test score is entered the user should be re-prompted to enter a new value until a valid score is entered.

7. Final Challenge: Complete this only after you have completed all of the tasks have sufficient time. Copy of the code into a new file and break the program down so that it utilises methods to handle each of the menu items.

Part D Testing

You should be testing your program as each stage is completed, and again once the program is complete. You should document the testing data, process and results (e.g. in the form of a table) and include this within your project documentation. Your mark for this section will reflect the thoroughness of your testing and the quality of your documentation.

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.