Hello,

I was wondering if someone could just explain me how to write a program. I am having a hard time trying to start writing my code. I can show you what I wrote so far.

This is the problem:

Part A: 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

Part B: 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. 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

The average age was 36.

The youngest person in attendance was 16.

The oldest person in attendance was 68.

Part C: Modify your program so that it also asks for the gender of each attendee. Your program should then break the attendance down by gender as well as by age. Sample screen output:

Enter age of attendee (negative number to quit): 34

Enter gender (M or F): M

Enter age of attendee (negative number to quit): 16

Enter gender (M or F): M

Enter age of attendee (negative number to quit): 68

Enter gender (M or F): F

Enter age of attendee (negative number to quit): 53

Enter gender (M or F): F

Enter age of attendee (negative number to quit): 39

Enter gender (M or F): F

Enter age of attendee (negative number to quit): 23

Enter gender (M or F): F

Enter age of attendee (negative number to quit): 21

Enter gender (M or F): F

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

males: 2

females: 5

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 (the user enters a negative number the first time).

I was wondering if someone could just explain me how to write a program. I am having a hard time trying to start writing my code. I can show you what I wrote so far.

This is the problem:

Part A: 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

Part B: 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. 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

The average age was 36.

The youngest person in attendance was 16.

The oldest person in attendance was 68.

Part C: Modify your program so that it also asks for the gender of each attendee. Your program should then break the attendance down by gender as well as by age. Sample screen output:

Enter age of attendee (negative number to quit): 34

Enter gender (M or F): M

Enter age of attendee (negative number to quit): 16

Enter gender (M or F): M

Enter age of attendee (negative number to quit): 68

Enter gender (M or F): F

Enter age of attendee (negative number to quit): 53

Enter gender (M or F): F

Enter age of attendee (negative number to quit): 39

Enter gender (M or F): F

Enter age of attendee (negative number to quit): 23

Enter gender (M or F): F

Enter age of attendee (negative number to quit): 21

Enter gender (M or F): F

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

males: 2

females: 5

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 (the user enters a negative number the first time).

I can show you what I wrote so far. |

Please do. It helps to see how much you already understand.

And post your compiler output, if it doesn't compile.

These things will help us a lot, and will attract more replies.

Hope al goes well.

Topic archived. No new replies allowed.