How to fix the infinite loop in this source code: #include #include using namespace std; int main(){ int price, contOp; while (true){ cout << setw(32)<<"List of Services Available"<> price; switch (price){ case 1: cout << "Service Fee: Php 500"; break; case 2: cout << "Service Fee: Php 400"; break; case 3: cout << "Service Fee: Php 1000"; break; case 4: cout << "Service Fee: Php 500"; break; case 5: cout << "Service Fee: Php 3500"; break; } cout<<"\nDo you want to View Another Service Fee?\n[Y or y] Yes\n[N or n] No"<>contOp; if(contOp=='N' || contOp=='n'){ cout<<"\nThank you for using this system… Have a great day!"; break; } } return 0; }
How to fix the infinite loop in this source code:
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int price, contOp;
while (true){
cout << setw(32)<<"List of Services Available"<<endl;
cout << setw(30)<<"Xray/Radiology Services (1)"<<endl;
cout << setw(30)<<"Laboratory Services (2)"<<endl;
cout << setw(30)<<"Blood ervices (3)"<<endl;
cout << setw(30)<<"Prescription Services (4)"<<endl;
cout << setw(30)<<"Dental Services (5)"<<endl;
cout << "\nChoose the Services You Want" <<endl;
cout << "Please Enter the Corresponding Service Option: ";
cin >> price;
switch (price){
case 1:
cout << "Service Fee: Php 500";
break;
case 2:
cout << "Service Fee: Php 400";
break;
case 3:
cout << "Service Fee: Php 1000";
break;
case 4:
cout << "Service Fee: Php 500";
break;
case 5:
cout << "Service Fee: Php 3500";
break;
}
cout<<"\nDo you want to View Another Service Fee?\n[Y or y] Yes\n[N or n] No"<<endl;
cout<<"Enter Here: ";
cin>>contOp;
if(contOp=='N' || contOp=='n'){
cout<<"\nThank you for using this system… Have a great day!";
break;
}
}
return 0;
}
Step by step
Solved in 3 steps with 1 images