Hi,
I wonder if somebody can see my error?
I would assume that these if statements would be valid only if 'y' or 'Y' is entered, and if any other character is entered the default string declared for the variables would be displayed, however this is not the case! I have looked over this section of code so many times and can not see my error.
any input would be greatly appreciated.
I wonder if somebody can see my error?
I would assume that these if statements would be valid only if 'y' or 'Y' is entered, and if any other character is entered the default string declared for the variables would be displayed, however this is not the case! I have looked over this section of code so many times and can not see my error.
any input would be greatly appreciated.
Code:
void main(void)
{
char alarmTime [30]= "no alarm call required";
char answer, answer2;
char thisFirstName[30];
char thisSecondName[30];
char thisCarReg [30] = "no vehicle registered";
guest newguest;
clrscr();
cout << "Enter new guests first name: ";
gets(thisFirstName);
cout << "Enter new guests sir name: ";
gets(thisSecondName);
cout << "does the guest have a car? y or n: ";
cin >> answer;
if (answer == 'y'|| 'Y')
{
cout << "Enter new guests car registration number ";
gets(thisCarReg);
}
cout << "would the guest like an alarm call? y or n: ";
cin >> answer2;
if (answer2 == 'y'|| 'Y')
{
cout << "Please enter the time of the alarm call: ";
cin >> alarmTime;
}
newguest.setGuestDetails(thisFirstName,thisSecondName, thisCarReg);
newguest.setAlarm(alarmTime);
cout << endl <<"Guest Name: "<< newguest.getFirstName()<< " " << newguest.getSecondName() << endl;
cout <<"Vehicle Registration: "<<newguest.getCarReg()<< endl;
cout <<"Alarm Call: " << newguest.getAlarm();
getchar();
}
Comment