A television rating service makes an Internet survey of the viewing audience to sample the popularity of TV shows. When a survey is made concerning a particular show, the age (in the range 1 to 120) and gender (male/female) of the person, as well as whether that person watches the show regularly (Y/N), are recorded. Design, write in Java, test and document a program to process the data gathered for a show. The program is to output the total number of people taking the survey, the number who said they watch the show regularly, and the percentage of those who watch the show regularly as in the example below.

The total number of people who took the survey = 50
The number of people who watch the show regularly = 25
The percentage of those who watch the show regularly = 50%

The program should also print a table showing the percentages of those who watch the show regularly according to gender and age categories as shown in the example below.

Distribution of viewers who watch the show regularly
--------------------------------------------------------------------------------
Gender % Under 35 % 35 or Over % Total
--------------------------------------------------------------------------------
Female 52 9 61
Male 35 4 39
--------------------------------------------------------------------------------
Total 87 13 100

The percentages in the table are rounded to the nearest whole number and are percentages of all those who watch the show regularly. Thus, the sum of percentages in the last column of the table must be 100% (ignoring any rounding error).

Sample input:

Enter next person’s age (1..120): 35
Enter this person’s gender (M/F): M
Enter whether this person watches the show regularly (Y/N): Y
Do you want to enter another person’s details (Y/N)? Y

The program should repeat until the user does not want to enter any more survey data for a particular show. The input data is to be validated. For example, if the user types in an integer outside the range 1 to 120 (for age), a letter other than 'M' or m (for male), F or f (for female), Y or y (watches regularly), N or n (does not watch regularly), the program should output an appropriate error message and re-prompt for input until the user enters the correct data.

Your program should have an outer loop that allows the user to repeat the above processing for a different show. The processing is repeated until the user indicates that they want to end the program. Think of a way that you can allow user to exit the program (not using Ctrl+C)

The program should be well-structured and should have a reasonable set of methods in addition to the main method. It should use a good coding style, proper indentation, meaningful identifier names and appropriate comments throughout. Devise suitable test data to test all sections of program code. You can hard code the test data in your submission so that your lecturer can run them to assess your submission. The test data together with test results should be submitted as part of your external documentation as well.

The program should also include a method (eg, StudentInfo( )) to output your student details (name, student number, mode of enrolment (i.e., internal or external), tutor name, tutorial attendance day and time) at the start of program results.

Note that this question does not require you to define a separate class for the person record and a separate client program. However, you are welcome to do so if you wish.

Note that the question does not require the use of arrays.

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.