Second loop isn't working properly

On the second loop, it should allow us to enter Individual Subject code but it directly showed the output without allowing me to enter the Individual Subject Code

#include<iostream>
#include<cstring>
#include<iomanip>

using namespace std;

int main()
{
char studentName[50];
char schoolName[30];
char category[10];
char codeOfPackage[10];
char codeOfTime;
char codeOfIndividualSub[10];
char codeOfCategory;
char registration = 'Y', choicesub = 'Y', addOn = 'Y';
char BMY, ENG, SEJ, MAT, SCI, GEO, BIO, CHE, PHY, ADD, ACC, ECO, MMA;
char type;
int contactNumber, PT3 = 0, SPM = 0, n, PTL = 0, PTA = 0, SPS = 0, SPA = 0, SPE = 0, PT3Sub = 0, SPMSub = 0, count=1, user=1;
int number1, number2, largest, smallest;
float tax, price = 0, pricePerSubject, TpricePT3=0, TpriceSPM=0, TpricePT1 =0, TpricePT2 =0, TpriceSPM1 =0, TpriceSPM2 =0, TpriceSPM3 =0;
float price1 = 0, price2 = 0 , price3 = 0, price4 = 0, price5 = 0, price6 = 0, price7 = 0, price8 = 0, price9 = 0, price10 = 0;
float price11 = 0, price12 = 0, price13 = 0, price14 = 0, price15 = 0, price16 = 0, price17 =0, price18 =0, price19 =0, price20 =0,price21 =0, price22 =0;
float price23 = 0, price24 = 0, price25 = 0, price26 = 0, price27 = 0, price28 = 0, price29 =0, price30 =0, price31 =0, price32 =0;

do
{
cout<<"\n========================================================================";
cout<<"\n\n Welcome to i-Excellent Tuition Academy "<<endl;
cout<<"\n========================================================================";

cout<<"\nThis is a registration form." <<endl;

cout<<"\nPlease enter your full name : " ;
cin>>ws;
cin.getline(studentName,50);
cout<<"\nPlease enter your school name : ";
cin.getline(schoolName,30);
cout<<"\nPlease enter your contact number : ";
cin>>contactNumber;
cout<<"\nPlease enter category ( PT3 / SPM ) : ";
cin>>category;

if (strcmp(category ,"PT3")==0 || strcmp(category ,"pt3")==0)
{
cout<<"\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|";
cout<<"\n| Category | Type of | Code of | Type of | Code of | Code of Individual | Subject | Time | Code of | Price per| Price per | |";
cout<<"\n| | Category | Category | Subject | Package | Subject | | | Time | package | individual | Tax |";
cout<<"\n|-------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|";
cout<<"\n| | | | LANGUAGE | PTL | BMY | Bahasa Melayu | Weekdays | D | 90 | 35 | |";
cout<<"\n| | | | | | ENG | English | Weekend | E | 70 | 35 | |";
cout<<"\n| | PACKAGE | P | | | SEJ | Sejarah | | | | 35 | |";
cout<<"\n| PT3 | / | / =======================================================================================================|============| 6 % |";
cout<<"\n| | INDIVIDUAL | I | STEM | PTA | MAT | Mathematics | Weekdays | D | 80 | 30 | |";
cout<<"\n| | | | | | SCI | Science | Weekend | E | 70 | 30 | |";
cout<<"\n| | | | | | GEO | Geography | | | | 30 | |";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------------------------|------------|-------|";

cout<<"\n\nPlease enter your type of category (P-Package / I-Individual) : ";
cin>>codeOfCategory;

if (codeOfCategory == 'P' || codeOfCategory == 'p')
{
cout<<"\n|-------------------------------------------------------------------------------------------------------------------------------------------------|";
cout<<"\n| Category | Type of | Code of | Type of | Code of | Code of Individual | Subject | Time | Code of | Price per |";
cout<<"\n| | Category | Category | Subject | Package | Subject | | | Time | package |";
cout<<"\n|-------------------------------------------------------------------------------------------------------------------------------------------------|";
cout<<"\n| | | | LANGUAGE | PTL | BMY | Bahasa Melayu | Weekdays | D | 90 |";
cout<<"\n| | | | | | ENG | English | Weekend | E | 70 |";
cout<<"\n| | | | | | SEJ | Sejarah | | | |";
cout<<"\n| PT3 | PACKAGE | P =======================================================================================================|";
cout<<"\n| | | | STEM | PTA | MAT | Mathematic | Weekdays | D | 80 |";
cout<<"\n| | | | | | SCI | Science | Weekend | E | 70 |";
cout<<"\n| | | | | | GEO | Geography | | | |";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------------------------|";

cout<<"\nPlease enter code of Package ( PTL-Language / PTA-STEM ) : ";
cin>>codeOfPackage;

if(strcmp(codeOfPackage,"PTL")==0 || strcmp(codeOfPackage,"ptl")==0)
{
cout<<"\nPlease enter code of time ( D-WEEKDAYS / E-WEEKEND ) : ";
cin>>codeOfTime;

if (codeOfTime == 'D' || codeOfTime =='d')
{
price=90.00;
}
else if (codeOfTime == 'E' || codeOfTime == 'e')
{
price=70.00;
}
else
{
price=0.00;
cout<<"\nERROR!";
}
//tax = 0.06;
TpricePT1 = price; //+ (price * tax);
}
else if(strcmp(codeOfPackage,"PTA")==0 || strcmp(codeOfPackage,"pta")==0)
{

cout<<"\nPlease enter code of time ( D-WEEKDAYS / E-WEEKEND ) : ";
cin>>codeOfTime;

if(codeOfTime == 'D' || codeOfTime =='d')
{
price=80.00;
}
else if(codeOfTime =='E' || codeOfTime =='e')
{
price=70.00;
}
else
{
price = 0.00;
}
//tax = 0.06;
TpricePT2 = price; //+ (price * tax);
}
else
{
price=0.00;
cout<<"\nERROR!";
}

cout<<"\nDo you want to add Individual Subject? : ";
cin>>addOn;
cout<<setprecision(2)<<fixed;
@Assh,
Please do two things:
(1) Provide a MINIMAL, COMPILEABLE example that illustrates your problem.
(2) Put your SMALL code sample within [code] [/code] tags.
Last edited on
if (addOn == 'Y')
{
for (int PT3Sub =0; PT3Sub <4; PT3Sub++)
{
cout<<"\n|-------------------------------------------------------------------------------------|";
cout<<"\n| Category | Code of Individual | Subject | Time | Code of | Price per |";
cout<<"\n| | Subject | | | Time | subject |";
cout<<"\n|-------------------------------------------------------------------------------------|";
cout<<"\n| | BMY | Bahasa Melayu | | | 35 |";
cout<<"\n| |--------------------|-----------------| | |-----------|";
cout<<"\n| | ENG | English | | | 35 |";
cout<<"\n| |--------------------|-----------------| | |-----------|";
cout<<"\n| | SEJ | Sejarah | Weekdays | D | 35 |";
cout<<"\n| |--------------------|-----------------| | |-----------|";
cout<<"\n| PT3 | MAT | Mathematics | Weekend | E | 30 |";
cout<<"\n| |--------------------|-----------------| | |-----------|";
cout<<"\n| | SCI | Science | | | 30 |";
cout<<"\n| |--------------------|-----------------| | |-----------|";
cout<<"\n| | GEO | Geography | | | 30 |";
cout<<"\n--------------------------------------------------------------------------------------|";

cout<<"\nHow many subject do you want to register (MAXIMUM - 4 SUBJECTS)? : ";
cin>>PT3Sub;

while (PT3Sub<0 || PT3Sub>4)
{
cout<<"ERROR!!";
cout<<"\nHow many subject do you want to register (MAXIMUM - 4 SUBJECTS)? : "; //over limit please choose until 4 subject
cin>>PT3Sub; //cin>>countI;
}

while(count<= PT3Sub)
{

cout<<"\n\nPlease enter code of Individual Subject : ";
cin>>codeOfIndividualSub;

while(strcmp(codeOfIndividualSub,"BMY")!=0 && strcmp(codeOfIndividualSub,"ENG")!=0 && strcmp(codeOfIndividualSub,"SEJ")!=0 && strcmp(codeOfIndividualSub,"MAT")!=0 && strcmp(codeOfIndividualSub,"SCI")!=0 && strcmp(codeOfIndividualSub,"GEO")!=0)
{
cout<<"ERROR!!";
cout<<"\n\nPlease enter code of Individual Subject : ";
cin>>codeOfIndividualSub;

}

if (strcmp(codeOfIndividualSub,"BMY")==0)
{
price17 = 35.00;
cout<<setprecision(2)<<fixed;
cout<<"\nPrice for Bahasa Melayu : RM" <<price17; //inside

}
else if (strcmp(codeOfIndividualSub,"ENG")==0)
{
price18 = 35.00;
cout<<setprecision(2)<<fixed;
cout<<"\nPrice for English : RM" <<price18; //inside

}
else if (strcmp(codeOfIndividualSub,"SEJ")==0)
{
price19 = 35.00;
cout<<setprecision(2)<<fixed;
cout<<"\nPrice for Sejarah : RM" <<price19; //inside

}
else if (strcmp(codeOfIndividualSub,"MAT")==0)
{
price20 = 30.00;
cout<<setprecision(2)<<fixed;
cout<<"\nPrice for Mathematics : RM" <<price20; //inside

}
else if (strcmp(codeOfIndividualSub,"SCI")==0)
{
price21 = 30.00;
cout<<setprecision(2)<<fixed;
cout<<"\nPrice for Science : RM" <<price21; //inside

}
else if (strcmp(codeOfIndividualSub,"GEO")==0)
{
price22 = 30.00;
cout<<setprecision(2)<<fixed;
cout<<"\nPrice for Geography : RM" <<price22; //inside

}
else
{
price = 0.00;
cout<<"\nERROR!!";
}
count++;
//cout<<"\nTotal price for taken subject(s) : RM" <<TpricePT3; //outside price

}
//TpricePT3 = (TpricePT1 + TpricePT2 + price17 + price18 + price19 + price20 + price21 + price22)*tax;
cout<<setprecision(2)<<fixed;


//PT3Sub++;
}

//cout<<"\n\nDo you want to add another registration? (Y-YES / N-NO) : ";
//cin>>registration ;
}
}
else
{
cout<<"error!";
}
user++;
}while (registration == 'Y');
return 0;
}
@Ashh, you were so busy posting voluminous amounts of code in FOUR separate posts(!) that you missed my attempt to offer advice:
http://www.cplusplus.com/forum/beginner/255155/#msg1118975
Topic archived. No new replies allowed.