0
case 'f':
case 'F':
  do
{
cout << "Enter Finish Time (Max Start + 24h, 0-23:59): ";
cin >> FinishTime;
						
if (FinishTime > 2359)
{
do
{	cout << "Error! Invalid Finish Time Input." << endl
	     << "Enter Finish Time (Max Start + 24h, 0-23:59): ";
	cin >> FinishTime;
} while (FinishTime > 2359);
}else
if (FinishTime == "q")
{
menu();
}else
if (FinishTime < 2400)
{
									
cout << "Yacht Time: ";
HoursConv(StartTime, FinishTime); 
cout << " hours, Yacht Avg Speed: "
<< AverageSpeed(CourseDistance, StartTime, FinishTime)
<<" knots, " << SpeedConv(AverageSpeed(CourseDistance, StartTime, FinishTime)) << " km/h" << endl;
}
				
}	while (FinishTime != "q" || FinishTime != "Q");		
break;

I can't get my function to call another function if the user input is "q" or "Q". if the user input is a "q" or any other things that aren't a number, the loop goes forever and ever. What I need is when the program asks for a user input in this case in a switch case and the user input is a "q" or "Q", the function will call my menu function and bring up the menu again. If the user input isn't a "q" or "Q", just an ordinary number, then it'll go ahead and calculate everything eg.averagespeed, etc.

Thank you!! It's driving me nuts!

Edited by kuramahiei: n/a

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by WaltP
0

Well since only half of the code is there it's difficult to tell.

My guess is that this is a function called from you menu function.

If so, it may be as simple as

replacing

if (FinishTime == "q")
{
menu();
}

with

if (FinishTime == "q")
{
return NULL;
}

Or something similar

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.