GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-Dec-2005, 00:58
leeang111 leeang111 is offline
New Member
 
Join Date: Nov 2005
Location: Alabama
Posts: 1
leeang111 is on a distinguished road
Unhappy

I need help with a conversion calculator.


Hello,

I am new to C++ programming. I am requesting help to understand
how to use a nested if/else statement to finish my project.
I don't expect you to write my program for me, but I would appreciate
any pointers you can give me. The program I have written so far has no
errors, but it is out of sequence. I just wrote what I understood.
I am learning how to use function prototypes. I am having difficulty
understanding how to tie everything back into main() function.
Here is the code I have so far. Please help me on this project.
Thanks.

CPP / C++ / C Code:
//	Author: Emily Gibson
//	Class:  CS300 Programming in C++, Fall 2005
//	Section: 02

//	Program: Lab_6_EmilyGibson
//	Version: ANSI/ISO C++
//	Date: December 2, 2005

//The purpose of this program is to provide the user with a means to perform
//conversion operations on units of measure and vice-versa. It also provides 
//the user with a termination option if the user prefers to quit the program. 
//This program will be accomplished using a multi-function program instead of 
//using a strictly int main () format.

#include <iostream>

using namespace std;

//function prototypes
char ConverMenu ();
double Fht2Cls(double);
double Cls2Fht(double);
double Gln2Lts(double);
double Lts2Gln(double);
double Mls2Klm(double);
double Klm2Mls(double);


int main ()
{
	//Declare and initialize variables.
	char operation = ' ';

		

	//Terminate
	return 0;
}//end function main()

//function definitions
char ConverMenu()
{
	//Declare variables and initialize
	char choice = ' ';

	//Display the user menu. The menu will be displayed using a do while statement because
	//by doing so the program menu and results will be guaranteed to display at least once.
	//This menu will use a clear screen operation, display the menu introduction message,
	//and it is designed to loop until a valid response from the user is received by the 
	//program. The while portion of the do while loop tells the program to continue looping
	// when the user input is not equal to a valid menu option.
	do 
	{		
		system ("cls");
		cout << "The purpose of this program is to provide the user with a means\n";
		cout << "to convert various units of measure to their metric counterpart\n";
		cout << "and vice-versa.\n"; 
		cout << "\nPlease select a conversion option from the menu below,\n";
		cout << "or if you prefer, you may choose to Quit the program.\n\n";
		cout << "'0' - Exit the program \n";
		cout << "'1' - Convert degrees Fahrenheit to degrees Celsius\n";
		cout << "'2' - Convert degrees Celsius to degrees Fahrenheit\n";
		cout << "'3' - Convert U.S. gallons to liters\n";
		cout << "'4' - Convert liters to U.S. gallons\n";
		cout << "'5' - Convert statute miles to kilometers\n";
		cout << "'6' - Convert kilometers to statute miles\n";
		cout << "\nPlease enter your conversion menu choice now: ";
		cin  >> choice;
		cin.clear();
	}
	while ((choice != '0') && (choice != '1') && (choice != '2') && (choice != '3')
			&& (choice != '4') && (choice != '5') && (choice != '6'));

	return choice;
}//end function ConverMenu()

//function Fht2Cls.
double Fht2Cls(double Fht)
{
	//Declare and initialize variables.
	double Cls = 0.0;
	Cls = (5/9 * (Fht - 32));
	return Cls;
}//end function Fht_to_Cls

//function Cls_to_Fht.
double Cls2Fht(double Cls)
{
	//Declare and initialize variables.
	double Fht = 0.0;
	Fht = (9/5 * (Cls + 32));
	return Fht;
}//end function Cls_to_Fht

//function Gln2Lts.
double Gln2Lts(double Gln)
{
	//Declare and initialize variables.
	double Lts = 0.0;
	Lts = (Gln * 3.785);
	return Lts;
}//end function Gln2Lts.

//function Lts2Gln.
double Lts2Gln(double Lts)
{
	//Declare and initialize variables
	double Gln = 0.0;
	Gln = (Lts / 3.785);
	return Gln;
}//end function Gln2Lts.

//function Mls2Klm.
double Mls2Klm(double Mls)
{
	//Declare and initialize variables.
	double Klm = 0.0;
	Klm = (Mls * 1.609344);
	return Klm;
}//end function Mls2Klm.

//function Klm2Mls.
double Klm2Mls(double Klm)
{
	//Declare and initialize variables.
	double Mls = 0.0;
	Mls = (Klm / 1.609344);
	return Mls;
}//end function Klm2Mls.
Last edited by LuciWiz : 03-Dec-2005 at 07:15. Reason: Please insert your C++ code between [c++] & [/c++] tags
 
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NFA to DFA conversion fiddler_808 CPP / C++ Forum 3 02-Jun-2006 12:49
Re: Conversion: Binary, Decimal, Hexadecimal WaltP C Programming Language 1 10-May-2006 06:49
Simple Calculator Application MOHAMMEDALI1989 Java Forum 1 06-Oct-2005 17:00
C (not C++) calculator conghaile C Programming Language 0 18-Apr-2005 11:15
Sydog's DVD to Divx Conversion Guide asanthadenz Computer Software Forum - Windows 1 14-Mar-2003 14:08

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:53.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.