Heres what I have to do I have to write a program that asks theuser what hotel s
ID: 3609266 • Letter: H
Question
Heres what I have to do I have to write a program that asks theuser what hotel suite they want which would then show theirselection along with the pricethis is the code:
#include<iostream>
#include<string>
using namespace std;
int main()
{
const int SZ = 5;
const char QUIT = 'z';
char answers[SZ] = {'a', 'b', 'c', 'd', 'e'};
double price[SZ] = {149.95, 215.66, 239.77, 308.11,500.99};
string suite[] = {"Alyse", "Botanical". "Crimson",
"Darlton", "Edwardian"};
char selection;
int x;
int flag;
cout << "Enter your choice of our hotel suites"<< endl;
for(x = 0; x < SZ; ++x){
cout << answers[x] << "for the " << suite[x] << " suite" << endl;
cout << "Enter " << QUIT << " toquit ";
cin << selection;}
while(selection != QUIT)
{
flag = 0;
for(x = 0; x < SZ ; ++x)
if(selection == answers[x])
{
cout <<"Price per night for the " << suite[x] <<
" is$" << price[x] << endl;
flag = 0;
}
if(flag = 0)
cout << "Sorry - invalid selection"<< endl;
cout << "Enter next selectionor " << QUIT << " to quit ";
cin >> selection
}
return 0;
}
notice the flag variable which would issue a message if a wronghotel has been picked
i think the errors are pure syntax errors but I cannot find themand as I changed the code I either crashed it or got a never endingloop
please help and if possible keep the code as it is or close toit