This is a simple one, but don't know why it won't work.

Question

VALUE RETURNING FUNCTIONS WITH ONE OR MORE VALUE PARAMETERS

The pupils of the Annandale High School have to pay a fee for each extramural activity that they want to partake in.

These activities include sport, and other activities such as chess, ballet, etc. The fee for sport activities is R120 p/m

and for other activities, R100 p/m. Pupils get discount if they partake in more than 3 activities. A maximum of 7

activities is allowed. For partaking in 4 or 5 extramural activities, they get a discount of R75 on the total amount

payable for the month. For partaking in 6 or 7 extramural activities, they get a discount of R125. The school also has

a credit system, where pupils get credits for various tasks performed. Taking part in extramural activities also adds

to their number of credits. Your task is to write a program that calculates the pupil’s monthly fee, including the

discount if applicable. The program must also calculate the number of credits that the pupil obtained by partaking in

extramural activities. This process is repeated for the whole class, and the total amount that must be collected by the

teacher must be calculated and displayed. We will develop the program in stages.

You must only submit printouts for question 4c.

Question 4a: Start small

We give the main function below. Your task is to write a function, namely calcFee, that returns a variable of

type float. There are two value parameters of type int namely the number of sport activities and the number of

other activities that the pupil partake in. You’ll notice that we have already defined the const variables that you

will need. The program must calculate the monthly fee for a pupil. No discounts will be handled in this function –

we will deal with that in 4(b). Test your program with different input values, but do not submit any printouts.

Program:

```
//Assignment 2 Question 4a
#include <iostream>
using namespace std;
const float feeSport = 120.00;
const float feeOther = 100.00;
const float discount = 50.00;
const float creditS = 0.75;
const float creditO = 0.50;
//Your function calcFee must be inserted here
int main()
{
int nrSport, nrOther, number;
float totFee = 0, newFee = 0, credits = 0, totSport = 0, totOther = 0;
do
{
cout << "A total number of 7 activities are allowed:-" ;
cout << endl <<endl;
cout << "Please enter the number of sport activities : " << endl;
cin >> nrSport;
cout << "Please enter the number of other activities : " << endl;
cin >> nrOther;
}while (nrSport + nrOther > 7);
96
totFee = calcFee(nrSport, nrOther);
cout.setf(ios::fixed);
cout.precision(2);
cout << endl << "The monthly fee payable is : R" << totFee ;
cout << endl << endl;
return 0;
}
```

My answer

```
//Your function calcFee must be inserted here
float calcFee (feeSport + feeOther);
int main()
{
int nrSport, nrOther, number;
float totFee = 0, newFee = 0, credits = 0, totSport = 0, totOther = 0;
do
{
cout << "A total number of 7 activities are allowed:-" ;
cout << endl <<endl;
cout << "Please enter the number of sport activities : " << endl;
cin >> nrSport;
cout << "Please enter the number of other activities : " << endl;
cin >> nrOther;
}while (nrSport + nrOther > 7);
totFee = calcFee (nrSport, nrOther);
cout.setf(ios::fixed);
cout.precision(2);
cout << endl << "The monthly fee payable is : R" << totFee ;
cout << endl << endl;
return 0;
}
```