Question #159684

At KWT College of Education, students pay R3500 for a module and they are allowed to register for a 

minimum of two and a maximum five modules per semester. In order for students to register they must 

pay at least a minimum registration fee of R2000. The remaining amount must then be paid in four equal 

payments at the end of March, April, May and at the end of June. 

Write a C++ program that will help determine the amount payable by doing the following:

 Declare all constants and necessary variables.

 Prompt the user for the student number or XXX to exit (see Figure 3.1).

 Determine if the number of subjects entered is valid by making use of a pre-test loop.

o If a valid student number is entered, do the following: 

 Prompt the user for the number of modules and the registration fee as shown in 

Figure 3.2.

 Validate the number of modules and the registration fee using the


Expert's answer

#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
	int min = 2;
	int max = 5;
	int pay = 3500;
	int regmin = 2000;
	string studnum="000";
	int N = 0, k = 0, modul, reg;
	cout << "Enter maximum number of students: ";
	cin >> N;
	while (k<N)
	{
		cout << "Enter the student number: ";
		cin >> studnum;
		if (studnum == "XXX")
		{
			exit(0);
		}
		cout << "How many modules need to select?\nAnswer: ";
		cin >> modul;
		if ((modul > max) || (modul < min))
		{
			cout << "Invalid number of modules!\n";
			exit(0);
		}
		cout << "Enter the down payment (at least 2000): ";
		cin >> reg;
		if (reg < regmin)
		{
			cout << "Invalid number of payment!\n";
			exit(0);
		}
		cout << "The student under the number "<<studnum<<" must pay: " << (modul*pay) - reg<<endl;
		k++;
	}
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS