Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It's Java not C++ Assignment 5.3 [40 points] This program is broken down into phases for your convenience only. Please turn in only the final

It's Java not C++

Assignment 5.3 [40 points]

This program is broken down into phases for your convenience only. Please turn in only the final phase. Before turning in your program, please make sure that it does something reasonable if the user enters a negative number the first time.

Don't use arrays in this program.

Important Hint: You will save yourself a lot of time and anguish if you follow the patterns and examples given in the lesson closely! Almost everything you need to do for this assignment can be found in an example in the lesson. Your primary job is figuring out how to put them together.

Phase 1: Write a program for a theater that will keep track of how many people in each of 5 age categories attended a particular movie. Use the 5 age categories listed below in the sample screen output. The user will enter a number of ages, entering a negative number when there are no more ages to enter. Your program will then report on how many people in each age group attended. Sample screen output:

 Enter age of attendee (negative number to quit): 34 Enter age of attendee (negative number to quit): 16 Enter age of attendee (negative number to quit): 68 Enter age of attendee (negative number to quit): 53 Enter age of attendee (negative number to quit): 39 Enter age of attendee (negative number to quit): 23 Enter age of attendee (negative number to quit): 21 Enter age of attendee (negative number to quit): -1 age 0 to 18: 1 age 19 to 30: 2 age 31 to 40: 2 age 41 to 60: 1 over 60: 1 

Phase 2: Modify your program so that, in addition to the report that the program currently produces, it also gives the average age of the people in attendance, the age of the oldest person in attendance, and the age of the youngest person in attendance. You may not assume any maximum age of attendees!

Don't forget to look at the examples in lesson 4 for help with this!

Sample screen output:

 Enter age of attendee (negative number to quit): 34 Enter age of attendee (negative number to quit): 16 Enter age of attendee (negative number to quit): 68 Enter age of attendee (negative number to quit): 53 Enter age of attendee (negative number to quit): 39 Enter age of attendee (negative number to quit): 23 Enter age of attendee (negative number to quit): 21 Enter age of attendee (negative number to quit): -5 age 0 to 18: 1 age 19 to 30: 2 age 31 to 40: 2 age 41 to 60: 1 over 60: 1 The average age was 36. The youngest person in attendance was 16. The oldest person in attendance was 68. 

Phase 3: Modify your program so that it also asks for each attendee's food preference ('p' for popcorn, 's' for soda, 'b' for both). Your program should then report this data as well.

Hint: The lessons contain an example of a loop like this where two questions are asked. Follow the pattern in that example.

Sample screen output:

 Enter age of attendee (negative number to quit): 34 Enter food preference ('p' for popcorn, 's' for soda, 'b' for both): s Enter age of attendee (negative number to quit): 16 Enter food preference ('p' for popcorn, 's' for soda, 'b' for both): b Enter age of attendee (negative number to quit): 68 Enter food preference ('p' for popcorn, 's' for soda, 'b' for both): b Enter age of attendee (negative number to quit): 53 Enter food preference ('p' for popcorn, 's' for soda, 'b' for both): s Enter age of attendee (negative number to quit): 39 Enter food preference ('p' for popcorn, 's' for soda, 'b' for both): p Enter age of attendee (negative number to quit): 23 Enter food preference ('p' for popcorn, 's' for soda, 'b' for both): s Enter age of attendee (negative number to quit): 21 Enter food preference ('p' for popcorn, 's' for soda, 'b' for both): s Enter age of attendee (negative number to quit): -1 age 0 to 18: 1 age 19 to 30: 2 age 31 to 40: 2 age 41 to 60: 1 over 60: 1 food preference popcorn: 1 food preference soda: 4 food preference both: 2 The average age was 36. The youngest person in attendance was 16. The oldest person in attendance was 68. 

Your program should do something reasonable if no ages are entered (i.e. the user enters a negative number the first time).

Turn in your source code from phase 3 and your output. Turn in only one output, and make it match the sample screen output given above for phase 3 exactly.

Language is Java

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

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

Distinguish between bottleneck time and throughput time.

Answered: 1 week ago

Question

4. Identify the challenges facing todays organizations

Answered: 1 week ago