The code is pretty much a mess, a big mess.
but i will post it, it has tooo many loops
i hope you give few minutes to try to run it and inform me of where did it go wrong
i figured out how to increment but it really goes wrong, at some point it starts adding more than 1.
while i know that i have added too many things and too many loops but starting again is not an option.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
ifstream in;
ofstream out;
string info, name1;
int TC; //TC stands for "Ticket Category
in.open("tickets.txt", ios::app);
out.open("tickets.txt",ios::app);
char entry;
int countP=1, countG=51, countS=201, countB=401, reopen=1, TCreopen, countUn, phoneUn, idUn, PlatinumTno=0, GoldTno=0, SilverTno=0, BronzeTno=0;
while(in>>countUn>>idUn>>name1>>phoneUn){
if (countUn>=1 && countUn<=50){PlatinumTno++;}
else if (countUn>=50 && countUn<=200) {GoldTno++;}
else if (countUn>=200 && countUn<=400) {SilverTno++;}
else if (countUn>=400 && countUn<=1000) {BronzeTno++;}}
do{
do
{ cout<<"The main menu:\n a. Issue a new ticket\n b. Cancel ticket reservation\n c. Print out customer purchase\n d. Show income statistics\n e. Choose random winner\n f. Exit\n";
cin>>entry;}
while (entry != 'a' && entry != 'A');
do {
if (entry == 'a' || entry == 'A'){
do{ cout<<"The options for ticket reservation are: \n 1. Platinum\n 2. Gold\n 3. Silver\n 4. Bronze\n";
do{cin>>TC;
cin.ignore(); //This is the only way we found to make getline(cin, info) work proberly
if (TC==1 && countP <=50){
if(PlatinumTno!=0){countP= countP + PlatinumTno;}
cout<<"Enter the id, firstname and phone of the customer consecutively in one line.\nfor example: 123456789 Ahmed 12345678\n";
getline(cin, info);
cout<<"You have successfully booked a Platinum ticket.\n\n";
out<<countP<<" "<<info<<endl;countP++;}
else if(TC==1 && countP>50) {cout<<"There is no more bookable platinum tickets "<<endl;}
if (TC==2 && countG<=200)
{if(GoldTno!=0){countG= countG + GoldTno;}
cout<<"Enter the id, first name and phone of the customer consecutively in one line.\nfor example: 123456789 Ahmed 12345678\n";
getline(cin, info);
cout<<"You have successfully booked a Gold ticket.\n\n";
out<<countG<<" "<<info<<endl;countG++;}
else if(TC==2 && countG>200){ cout<<"There is no more bookable Gold tickets "<<endl;}
if (TC==3 && countS<=400){if(SilverTno!=0){countS= countS + SilverTno;}
cout<<"Enter the id, first name and phone of the customer consecutively in one line.\nfor example: 123456789 Ahmed 12345678\n";
getline(cin, info);
cout<<"You have successfully booked a Silver ticket.\n\n";
out<<countS<<" "<<info<<endl;countS++;}
else if(TC==3 && countS>400){ cout<<"There is no more bookable Silver tickets"<<endl;}
if (TC==4 && countB<=1000){if(BronzeTno!=0){countB= countB + BronzeTno;}
cout<<"Enter the id, first and phone of the customer consecutively in one line.\nfor example: 123456789 Ahmed Khaled 12345678\n";
getline(cin, info);
cout<<"You have successfully booked a Bronze ticket.\n\n";
out<<countB<<" "<<info<<endl;countB++;}
else if(TC==4 && countB>1000){ cout<<"There is no more bookable Br tickets"<<endl;}
if (TC!=1 && TC!=2 && TC!=3 && TC!=4) cout<<"Invalid choice, choose again.\n";}
while(TC != 1 && TC != 2 && TC != 3 && TC != 4);
}
while (TC != 1 && TC != 2 && TC != 3 && TC != 4);}
cout<<"Do you want to book a new or different ticket ?\n1.Yes \n2.No ";
cin>>TCreopen;} while(TCreopen==1);
}while (reopen==1);
out.close();
return 0;}