int main()
{
char ans, ticket;
int blue = 0;
int green = 0;
cout << "Start counting tickets? (y/n): ";
cin >> ans;
while (toupper(ans) == 'y')
{
cout << "Enter b for blue or g for green: ";
cin >> ticket;
while (toupper(ticket) == 'b')
{
blue++;
}
while (toupper(ticket) == 'g')
{
green++;
}
cout << "Count another ticket ? (y / n) : ";
cin >> ans;
}
cout << "There were " << blue + green << " attendees. " << blue << " had blue tickets and " << green << " had green tickets." << endl;
return 0;
}
Thank you YFGNG ! I didnt think that it would matter, learned something new. Although when I do this for 'g' and 'b' the program will stop once I enter B ,b ,g , or G.
edit: Actually I got it after switching them to if else