The learners must create a C++ program using FUNCTIONS to compute the tuition fee of the students in a chosen level. The program will allow the users to choose the level and using the functions, the program will ask the values needed to compute the tuition fee. There must be two functions to compute the tuition fee for grade 7 and 8 level. Please use grade7 and grade8 as FUNCTION NAMES.
#include<iostream>
using namespace std;
float grade7(float sum)
{
return sum*7;
}
float grade8(float sum)
{
return sum*8;
}
int main(int argc, char *argv[])
{
int grade;
float value;
float sum=0;
cout<<"\n7 - grade 7";
cout<<"\n8 - grade 8";
cout<<"\nPlease, choose the level:";
cin>>grade;
cout<<"Please, enter the values to compute the tuition fee (0-exit program):";
do
{
cin>>value;
if(value<=0)break;
sum+=value;
}while(true);
if(grade==7)
cout<<"the tuition fee is "<<grade7(sum);
else if(grade==8)
cout<<"the tuition fee is "<<grade8(sum);}
Comments
Leave a comment