
November 23rd, 2012, 01:05 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 1
Time spent in forums: 10 m 29 sec
Reputation Power: 0
|
|
|
General - C++ Looping Help!!!
do
{
cout<<"When did the call start?\n";
cout<<"Please enter the time in 24-hour notation.\n";
cin>>start_time;
cout<<"How long did the call last?\n";
cin>>minutes;
cout<<"Please enter the first two letters of the day of the call.\n";
cin>>first>>second;
if ((((first=='M')||(first=='m'))&&((second=='O')||(second=='o'))) || (((first=='T')||(first=='t'))&&((second=='U')||(second=='u'))) || (((first=='W')||(first=='w'))&&((second=='E')||(second=='e')))
|| (((first=='T')||(first=='t'))&&((second=='H')||(second=='h'))) || (((first=='F')||(first=='f'))&&((second=='R')||(second=='r'))))
{
if ((start_time>=800) &&(start_time<=1800))
{
cost=minutes*.40;
}
else
{
cost=minutes*.25;
}
}
else if ((((first=='S')||(first=='s'))&&((second=='A')||(second=='a'))) || (((first=='S')|| (first=='s'))&& ((second=='U')||(second=='u'))))
{
cost=minutes*.15;
}
else
{
cout<<"\nYour response is invalid. Please try again."<<endl;
cout << "Please enter the day of the call (Mo/Tu/We/Th/Fr/Sa/Su):";
cin >> first>>second;
}
How do I make the BOLD part to continuously prompt user until a valid response is given?
I tried using boolean, do-while, but I can't seems to make it work.
Please help.
|