Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA A tv rating service makes an internet survey of the viewing audience to sample the popularity of some TV shows. When information is collected

JAVA

A tv rating service makes an internet survey of the viewing audience to sample the popularity of some TV shows. When information is collected concerning a particular show, the age (in the range 1 to 105) and gender (male/female) of the person surveyed, 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 surveyed, the number who said they watch the TV show regularly, and the percentage of those who watch the TV show regularly as in the example below. The total number of people surveyed = 100 The number of people who watch the show regularly = 20 The percentage of those who watch the show regularly = 20% The program should also print a table showing the percentages of those who watch the show regularly according to gender and age categories as in the example below. Distribution of viewers who watch the show regularly -------------------------------------------------------------------------------------------------- Gender % Under 30 % 30 or Over % Total -------------------------------------------------------------------------------------------------- Female 44 17 61 Male 23 16 39 -------------------------------------------------------------------------------------------------- Total 67 33 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: Please enter the persons age (1..105): 25 Please enter the persons gender (M/F): M Please enter whether the person watches the show regularly (Y/N): Y Do you want to enter another persons 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 105 (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) Note that the question does not require the use of arrays. 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. 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. Devise suitable test data (in addition to the above example) to test your program. The test data together with test results should be submitted as part of your external documentation.

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

State the characteristics of sound net working capital management.

Answered: 1 week ago

Question

(6) If E(X) = 1 and E(X2) = 2, then the variance is 2. Pg45

Answered: 1 week ago

Question

explain what is meant by the terms unitarism and pluralism

Answered: 1 week ago