Hi, I am making an student registration program as my project in school. But I had some problems making it. Our professor asked us to make an program where there are lists of subjects offered. Then the student will choose what subject/subjects he/she likes, then it will be computed. The tuition fee etc. My problem is at the end where I need to add all of the Tuition fee, Misc. Fee etc. It doesn't sum up. And if you enter 2 subjects the latest subject will only be the one that the unit is computed. pls. help I need this tomorrow. thanks.

#include<iostream.h>
#include<conio.h>
main()
{
int choice, unit, lab=0, tunit=0, total, tfee=0, y=5;
char ans;
clrscr();
cout<<"Offered Subjects";
cout<<"1. COE";
cout<<"2. MATH";
cout<<"3. Exit";
loop:
gotoxy(50,10);
cout<<"Enter your choice";
cin>>choice;
switch(choice)
{
case 1:
unit=4;
lab=1200;
y++;
gotoxy(50,y);
cout<<"COE	       "<<unit;
tunit=unit*130;
break;

case 2:
y++;
unit=3;
gotoxy(50,y);
cout<<"MATH	       "<<unit;
tunit=unit*130;
break;

default:
cout<<"Invalid Choice";
}
gotoxy(10,45);

cout<<"Do you want another transaction?";
cin>>ans;
if(ans=='Y'||ans=='y'){
goto loop;}
else{
goto loop1;
}
loop1:
tfee=tunit;
gotoxy(50,y+2);
cout<<"Tuition		"<<tfee;
gotoxy(50,y+3);
cout<<"Laboratory	"<<lab;
gotoxy(50,y+4);
cout<<"Miscellaneous	"<<"1,920";
gotoxy(50,y+5);
cout<<"Others		"<<"100";
gotoxy(50,y+6);
cout<<"Drug Testing	"<<"200";
gotoxy(50,y+7);
cout<<"Mailing Fee	"<<"60";
gotoxy(50,y+8);
cout<<"========================";
gotoxy(50,y+9);
cout<<"Total		"<<total;
total=tfee+lab+1920+100+200+60;
getch();
return 0;
}

Try indenting your code between braces. It will be a lot easier to read.

Comments:

1. Use loops with control values, not goto statements. I'd fail you for that alone if I were teaching the class.

2. This is a C++ class. You are writing C code. Structure your application with classes - one for the ClassesOffered, and one for Student. The Student class will contain a vector of classes that are taken by each student. Create the appropriate methods for each class, such as name, creditHours, and cost for the ClassesOffered class, and name, classesTaken for Student. One of the methods for the Student class would logically be to compute the total cost for that student. Constant values such as Miscellaneous and Mailing fees should be assigned to constant variables which you would use in computing costs in the Student class.

3. Don't use the gotoxy(x,y) function to position the data on the screen. That is not a standard C++ construct and will only work on a few systems/compilers. Just use output to cout and let the screen scroll.

you have used switch statement which only lets you support selecting only one subject....try with if condition...n define a global variable like sum-0...then add all the fees one by one in this variable...while keeping subjects selected in every if condition....if applicable

n define a global variable like sum-0

There's absolutely no need for a global variable whatsoever.
Also there appears to be something wrong with your keyboard. Your dot-key is stuck and the shift-key (for Capitals) seems to be broke.

Hi, Thanks to every one who helped. I have figured it out already right on the spot! haha. While our professor are checking the programs suddenly I have fixed it, I'm really happy right now since only a few of us have been successful. Thank you for everyone who tried to answer.

so this is what I did:

#include<iostream.h>
#include<conio.h>
main()
{
int choice, unit, lab=0, tunit=0, total, tfee=0, y=5;
char ans;
clrscr();
cout<<"Offered Subjects";
cout<<"1. COE";
cout<<"2. MATH";
cout<<"3. Exit";
loop:
gotoxy(50,10);
cout<<"Enter your choice";
cin>>choice;
switch(choice)
{
case 1:
unit=4;
lab=1200;
y++;
gotoxy(50,y);
cout<<"COE	       "<<unit;
tunit=unit*130;
break;

case 2:
y++;
unit=3;
gotoxy(50,y);
cout<<"MATH	       "<<unit;
tunit=unit*130;
break;

default:
cout<<"Invalid Choice";
}
gotoxy(10,45);

cout<<"Do you want another transaction?";
cin>>ans;
if(ans=='Y'||ans=='y'){
goto loop;}
else{
goto loop1;
}
loop1:
tfee=tunit;
total=tfee+lab+1920+100+200+60;
gotoxy(50,y+2);
cout<<"Tuition		"<<tfee;
gotoxy(50,y+3);
cout<<"Laboratory	"<<lab;
gotoxy(50,y+4);
cout<<"Miscellaneous	"<<"1,920";
gotoxy(50,y+5);
cout<<"Others		"<<"100";
gotoxy(50,y+6);
cout<<"Drug Testing	"<<"200";
gotoxy(50,y+7);
cout<<"Mailing Fee	"<<"60";
gotoxy(50,y+8);
cout<<"========================";
gotoxy(50,y+9);
cout<<"Total		"<<total;
getch();
return 0;
}
This question has already been answered. Start a new discussion instead.