222k views
1 vote
An organization wishing to attract more people decides to base its

membership fees on the age of the member. Also, wanting members to
attend more activities, it gives a reduction on the membership fee for each
activity attended in the previous year.
The following table depicts the corresponding fee and reductions. The
minimum membership fee is $1, even if the member attended a lot of
activities.
Age
6 years or less
7-12 years
13-18 years
Over 18 years
Membership
Fee Reduction per Activity
$0.75
$1.25
$2
$5
$10
$15
$25
$2
Write a program that asks the user to input their age and the number of
activities attended and then displays the corresponding membership fee.
Input Validation: Do not accept a negative value for either the age or the
number of activities


C++

User Manuelarte
by
8.5k points

1 Answer

1 vote

1. Begin the program by including the header file <iostream> which includes basic input/output library functions as well as the <vector> library which is needed for this program.

2. Declare a vector of integer type named 'ageGroups' which will store the age groups and the corresponding membership fee and reductions.

3. Create a void function named 'calculateFee()' which will take a parameters age and activities attended.

4. In the calculateFee() function, use the switch statement for the age group and store the corresponding membership fee and reduction value in variables.

5. Use an if statement to check that the number of activities attended is non-negative.

6. Calculate the membership fee using the variables and store it in a variable named 'fee'.

7. Use an if statement to check if the fee is less than 1 and if yes, assign the fee to 1.

8. Print the fee to the user.

9. End the program.

User Derek Wright
by
7.9k points