Need fixing and refining

Create a program that lets the user enroll a college student. Discounts are given for the in percentage. The user will have unpaid balance if he/she chooses to pay the partial instead of the full payment.

A. Login

Upon loading the program, the user must login to the system:

Username: regi
Password: enroll2015
If the user inputs a wrong username or password, ask the user to try again or to exit.

B. Main Menu

There are 3 choices for the main menu (type a number to choose)
1) REGISTRATION
2) PAYMENT
4) EXIT

C. REGISTRATION Function

Input Student’s Name.
There are 4 choices for the REGISTRATION menu (type a number to choose)
1) Register 5 subjects
2) Register 6 subjects
3) Register 7 subjects
4) Back to Main Menu

Display the following:

Student’s Name
Number of registered subjects
Total number of registered units (3 units per subject)
Total Tuition Fee (Php 700.00 per unit)
D. PAYMENT FUNCTION (allow only if registration is complete)

Input discount percentage.
Display the following:

Student’s Name
Number of registered subjects
Total number of registered units (3 units per subject)
Total Tuition Fee (Php 700.00 per unit)
Total discount in Peso.
Tuition Balance (tuition fee less discount)
Input Payment (payment must not be less than 30% of tuition balance)
Display unpaid balance (tuition balance less payment).

I'm done with the A and B part it works but I have a problem with my C part when I choose between the choices it doesn't work it just says "no such choice".


#include<iostream>

using namespace std;
string studentname[10];
int totaltuition=0;
int numberofsub=0;
int numberofunits=0;
int discount=0;
int tuitionbalance=0;
int payment=0;
int temp=0;
int temp2=0;
double p;
int k=1;

void REGISTRATION() //this is the part I need help
{
int choice;

cin.ignore();
cout<<"Enter the student's name"<<endl;
getline(cin,studentname[k]);

cout<<"1) Register 5 subjects"<<endl
<<"2) Register 6 subjects"<<endl
<<"3) Register 7 subjects"<<endl
<<"4) Back to Main Menu"<<endl
<<"Student's name :"<<"\""<<studentname[k]<<"\""<<endl
<<"Number of registered subjects :"<<numberofsub<<endl
<<"Total number of registered units :"<<numberofunits<<endl
<<"Total Tuition Fee :"<<totaltuition<<endl;
cin>>choice;

switch(choice){

case 1:
{
cout<<"Successfully registered 5 subjects "<<endl;
numberofsub+=5;
totaltuition+=(700*(5*3));
numberofunits+=(5*3);


break;
}
case 2:
{

cout<<"Successfully registered 6 subjects "<<endl;
numberofsub+=6;
totaltuition+=(700*(6*3));
numberofunits+=(6*3);

break;
}
case 3:
{

cout<<"Successfully registered 7 subjects "<<endl;
numberofsub+=7;
totaltuition+=(700*(7*3));
numberofunits+=(7*3);

break;
}
case 4:
{

cout<<"Successfully went back to main menu"<<endl;

break;
}
default:

cout<<"No such choice"<<endl;
}
}

void PAYMENT()
{

cout<<"Input discount percentage"<<endl;
cin>>p;
cout<<"Enter your payment"<<endl;
cin>>payment;
p=p/100;
discount=totaltuition*p;
tuitionbalance=totaltuition-discount;
temp=tuitionbalance*0.30;
temp2=tuitionbalance-payment;
cout
<<"Student's name :"<<"\""<<studentname[k]<<"\""<<endl
<<"Number of registered subjects :"<<numberofsub<<endl
<<"Total number of registered units :"<<numberofunits<<endl
<<"Total Tuition Fee :"<<totaltuition<<" Php"<<endl
<<"Total discount in Peso :"<<discount<<" Php"<<endl
<<"Tuition Balance :"<<tuitionbalance<<" Php"<<endl;

if(payment>temp)
{
cout<<"Unpaid balance : ";
cout<<temp2<<" Php"<<endl;
totaltuition=temp2;
}
else
{
cout<<"Payment less than 30% of the tuition balance is not accepted"<<endl;
cout<<"Unpaid balance :"<<(tuitionbalance)<<" Php"<<endl;
}
}

int main()
{
int r;
int x;
int y;
string user;
string pass;
string word="enroll2015";
string name="regi";
int ans;

cout<<"Username:";
cin>>user;
cout<<endl;
cout<<"Password:";
cin>>pass;
cout<<endl;

if(user!=name||pass!=word)
{
cout<<"Wrong username or password please try again"<<endl;
return 0;
}
else
cout<<"Success! "<<endl;
do
{
cout<<"*************Main Menu*************"<<endl
<<"1) REGISTRATION"<<endl
<<"2) PAYMENT"<<endl
<<"3) EXIT"<<endl
<<"***********************************"<<endl;
cin>>y;
switch(y)

{
case 1:

cout<<"You have chosen Registration "<<endl;

REGISTRATION();
r=r+1;
break;
case 2:

cout<<"You have chosen Payment"<<endl;

if(r>0){
if(temp2>=0)
PAYMENT();
else

cout<<"Already fully paid"<<endl;

}
else
cout<<"Have not yet registered "<<endl;

break;
case 3:

cout<<"Successfully exited the program"<<endl;

break;
default:

cout<<"No such choice"<<endl;

break;
}
}while(y!=3);
return 0;
}
Last edited on
Why does it need fixing? Does it not work? Do you get Errors? If so, post the errors here.

And please edit your post and all of your code between code tags - http://www.cplusplus.com/articles/jEywvCM9/
Yes I get errors and I don't understand why. Please, kindly copy paste the code then you'll see the problem.
Why does it need fixing? Does it not work? Do you get Errors? If so, post the errors here.

And please edit your post and all of your code between code tags - http://www.cplusplus.com/articles/jEywvCM9/
Last edited on
Topic archived. No new replies allowed.