can someone please help; its telling me that case 2 not within a switch case?
how do i keep count of the code the user selected
for example how many students calculated under case 1
#include<iostream.h>
#include<conio.h>
main()
{
char name[25];
int code;
int credits;
int tuition,sum=0;
int student_count=0;
int PT_count=0;
int FT_count=0;
cout<<"Enter Student Name"<<endl;
cin>>name;
cout<<"Enter 1 if student is a resident or\n[ Enter 2 if a student is not a resident"<<endl;
cin>>code;
while (code!=0)
{
switch(code)
case 1:
cout<<"Enter the credit amount"<<endl;
cin>>credits;
if(credits>=12)
tuition=600;
else
tuition=credits*50;
break;
case 2:
cout<<"Enter the credit amount"<<endl;
cin>>credits;
if (credits>=12)
tuition=1320;
else
tuition=credits*110;
break;
default:
cout<<"Invalid Code"<<endl;
You need to include any actions the code is to take in { } after each case.
Like if statements only the next part of the line or next line is considered as part of the case. to solve this for multi-line operations use the { } to encompass the desire code.
This kind of problem will often return an error similar to the one you reports.