Click here to Skip to main content
15,921,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralMFC ODBC Consumer Wizard Crashes Pin
Matt Gates23-Sep-03 6:22
Matt Gates23-Sep-03 6:22 
General[Message Deleted] Pin
imdx8023-Sep-03 6:05
imdx8023-Sep-03 6:05 
GeneralRe: Iterating Connection Names, Pin
Mike Dimmick23-Sep-03 7:32
Mike Dimmick23-Sep-03 7:32 
Generalwin95 global memory Pin
umarcool23-Sep-03 5:24
umarcool23-Sep-03 5:24 
Generalmenu Pin
sardinka23-Sep-03 4:31
sardinka23-Sep-03 4:31 
GeneralRe: menu Pin
RobJones23-Sep-03 4:56
RobJones23-Sep-03 4:56 
GeneralRe: menu Pin
sardinka23-Sep-03 5:15
sardinka23-Sep-03 5:15 
GeneralRe: menu Pin
RobJones23-Sep-03 5:56
RobJones23-Sep-03 5:56 
I didn't compile this so it may have errors.. At least I think you will get the basic idea...

BOOL OnPrompt();

int main(void)
{
	//Question:Will it be the best practice to do this: float c=0?
	//Question:I used float, but I am not sure if in this case better to use int or double?
 
	cout<<"Please select the task to perform:"<<endl;
	cout<<"Convert Fahrenheit to Centigrade (1)"<< endl;
	cout<<"Convert Centigrade to Fahrenheit(2)"<< endl;
	cout<<"Exit the program(3)"<< endl;
 	
	while(true)
	{
		if(OnPrompt())
			break;
	}
 
	return 0;
}
 
BOOL OnPrompt()
{
	int choice;
	float c; //Declare variable to be displayed.
	float f;

	cout<<"Please enter 1 or 2 (3 to exit program):";
	cin>>choice;
	switch (choice)
	{
		// use switch in order to do validation and calculation
		case 1:
		{
			cout<<"Enter value 
			in Fahrenheit:" ;
			cin>>f;
			c=((f-32)*5/9);
			cout<<"The value 
			in Centigrade is:"<<c<<endl;
			return TRUE;
			break;
		}
		case 2:
		{
			cout<<"Enter value in Centigrade:";
			cin>>c;
			f=((c+32)*9/5);
			cout<<"The value in Fahrenheit is:"<<f<<endl;
			return TRUE;
			break;
		}
		case 3:
		{
			cout<<"Thank you for using this program."<<endl;
			// If user enter 3 quit program
			// use return statement
			//Question:Is it any other way to quit the program other then use return?
			return TRUE;
			break;
		}
		default:
		{
			cout<<"Incorrect input"<< endl;
			return FALSE;
			// Default case used if user input the value outside the appropriate range
		}
	}
}



Rob



Whoever said nothing's impossible never tried slamming a revolving door!
GeneralRe: menu Pin
sardinka23-Sep-03 6:34
sardinka23-Sep-03 6:34 
GeneralRe: menu Pin
David Crow23-Sep-03 7:06
David Crow23-Sep-03 7:06 
GeneralRe: menu Pin
Atlantys23-Sep-03 8:01
Atlantys23-Sep-03 8:01 
GeneralRe: menu Pin
jhwurmbach23-Sep-03 21:18
jhwurmbach23-Sep-03 21:18 
GeneralRe: menu Pin
jhwurmbach23-Sep-03 5:18
jhwurmbach23-Sep-03 5:18 
GeneralRe: menu Pin
sardinka23-Sep-03 5:47
sardinka23-Sep-03 5:47 
GeneralRe: menu Pin
sardinka23-Sep-03 6:02
sardinka23-Sep-03 6:02 
GeneralRe: menu Pin
David Crow23-Sep-03 7:03
David Crow23-Sep-03 7:03 
Generalhelp on drawing application in VC++ Pin
swerajan23-Sep-03 4:31
swerajan23-Sep-03 4:31 
QuestionWhat Profiler message means ? Pin
vgrigor23-Sep-03 4:30
vgrigor23-Sep-03 4:30 
Generalmenu Pin
sardinka23-Sep-03 4:23
sardinka23-Sep-03 4:23 
GeneralRe: menu Pin
RobJones23-Sep-03 4:30
RobJones23-Sep-03 4:30 
GeneralRe: menu Pin
Chris Richardson23-Sep-03 11:04
Chris Richardson23-Sep-03 11:04 
QuestionWhat means such Profiler output ? Pin
vgrigor23-Sep-03 4:04
vgrigor23-Sep-03 4:04 
AnswerRe: What means such Profiler output ? Pin
Mike Dimmick23-Sep-03 5:53
Mike Dimmick23-Sep-03 5:53 
GeneralRe: What means such Profiler output ? Pin
vgrigor23-Sep-03 6:02
vgrigor23-Sep-03 6:02 
Generaldll shared data Pin
umarcool23-Sep-03 3:47
umarcool23-Sep-03 3:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.