I am making c++ program using do while loop but after inserting the condition while ( x =='y'|| x == 'Y');
I got an error where the loop is continued without letting me to insert the input again.
I can't insert the input until I stop the program.
#include <iostream>
using namespace std;
int main()
{
char str[30];
char symptom,quest;
char a,b,x,y,Y,n,N;
do{
cout<<" Enter your name: "<<endl;
cin.get(str,30);
cout<<"Hi " << str << ", Welcome to COVID test!"<<endl;
cout<<"Let's start the self testing test!"<<endl<<endl<<endl;
cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"<<endl;
cout<<" COVID SELF TESTING CENTRE "<<endl;
cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"<<endl<<endl;
cout<<"Do you have any symptoms below: (1-Yes, 2-No)"<<endl;
cout<<"Fever --> "<<endl;
cin>>a;
cout<<"Cough --> "<<endl;
cin>>a;
cout<<"Flu --> "<<endl;
cin>>a;
cout<<"Shortness of breath --> "<<endl;
cin>>a;
cout<<"Sore throat --> "<<endl;
cin>>a;
cout<<"Have you ever tested POSITIVE COVID-19 : "<<endl;
cin>>b;
cout<<"Do you had close contact with those who have been confirmed PORITIVE COVID-19 in the last 14 days? : "<<endl;
cin>>b;
cout<<"Do you have a history of traveling abroad or outside the state of Perak in the last 14 days? : "<<endl;
cin>>b;
cout<<"Are you currently undergoing a home quarantine control order by the Ministry of Health Malaysia? : "<<endl;
cin>>b;
cout<<endl<<endl;
cout<<"========================================================="<<endl;
cout<<" RESULT FOR COVID-19 SELF TESTING CENTRE "<<endl;
cout<<"========================================================="<<endl;
symptom=a;
quest=b;
if (symptom=='2'&&quest=='2')
{
cout<<"GREEN ZONE. Your status are low risk and no symptoms. Please folllow the SOP and Stay Safe Thank You!"<<endl;
}
if (symptom=='1'&&quest=='1')
{
cout<<"RED ZONE. Please get a clinically COVID-19 checkup from nearby hospital. Please folllow the SOP and Stay Safe Thank You!"<<endl;
}
if (symptom=='1'&&quest=='2')
{
cout<<"YELLOW ZONE. Please stay at home or self quarantine. Please folllow the SOP and Stay Safe Thank You!"<<endl;
}
if (symptom=='2'&&quest=='1')
{
cout<<"YELLOW ZONE. Please stay at home or self quarantine. Please folllow the SOP and Stay Safe Thank You!"<<endl;
}
cout<<"Ingin teruskan? (Y-yes, N-No): "<<endl;
cin>>x;
cout<<" ";
}while ( x =='y'|| x == 'Y');
system("pause");
return 0;
}