Hi Folks ,
yes i have finisched my "work" on this converter ,but not as i previously wanted ,i switched over to the "swith/case" thingy instead of the if function ,made it easier in the end and of course i did get me some ideas how to manage it from some other example programs ,which is not cheating as i guess
so here the final version :
Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
void Start ();
void GetResults();
const float FRACTION = 1.80; // Named constant definitions:
char x;
float fahrenheit; // fahrenheit temperature
float celsius; // celsius temperature
double cel,far,result; // some variables
void Start()
{
cout << " You can choose between those :\n"; // select Temp
cout << " 1. Celsius \n";
cout << " 2. Fahrenheit \n";
cout << " 3. or any other Key to Exit \n";
cin >> x;
cout << "\n\n";
switch (x)
{
case '1' : cel; // getting the choice
break;
case '2' : far;
break;
default : exit(0);
break;
}
GetResults();
}
void GetResults()
{
if (x=='1') // Chooce to convert in Fahrenheit
{
cout << " You choose Option ( 1 ) \n"; // calculating Celsius in Fahrenheit
cout << " Please enter a temperature in degrees Celsius: ";endl;
cin >> cel;
result = (cel * FRACTION ) + 32.0;
cout << " " << cel << " degrees Celsuis are " << result << " degrees Fahrenheit\n";endl;
cout << "\n";
}
if (x=='2') // Choose to convert in Celsius
{
cout << " You choose Option ( 2 )\n"; // calculating Fahrenheit in Celsius
cout << " Please enter a temperature in degrees Fahrenheit: ";endl;
cin >> far;
result = (far - 32.0 ) / FRACTION;
cout << " " << far << " degrees Fahrenheit are " << result << " degrees Celsius\n";endl;
cout << "\n";
Start();
}
else if (x!= '1')
{
Start();
}
else if (x!='2')
{
Start();
}
else if (x!= '3')
{
Start();
}
}
// Main program:
int main()
{
cout.precision(4);
cout << "*************************************\n";
cout << "*** Temperature - Converter ***\n";
cout << "*** Designed by - ***\n";
cout << "*** +---- Karsten Mueller ----+ ***\n";
cout << "*** in September 2004 ***\n";
cout << "*** Version ***\n";
cout << "*** V 1.3 ***\n";
cout << "*************************************\n";
cout << endl;
cout << endl;
Start();
return 0;
}
thanks again for all your help and ideas ,i sure will continue and learn more while iam doing as well .
Hoschi