- Apr 10, 2001
- 48,775
- 3
- 81
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main()
{
double celsius;
double fahrenheit;
char m ;
char n;
//program introduction. Asks for confirmation to continue
cout << "WELCOME TO THE ULTRACONVERTOR 3000, YOUR SOURCE FOR TEMPERATURE CONVERSION," << endl;
cout << "FUFILLING ALL YOUR TEMPERATRUE NEED SINCE 1955" << endl;
cout << "\nWOULD YOU LIKE ME TO CONVERT TEMPERATURES TODAY?" << endl;
cout << "TYPE YES OR NO TO CONTINUE" << endl;
cin >> m;
//decides whether they typed yes or no by simply checking the first letter
switch( m ) {
case 'y':
case 'Y':
cout << "\n\n\ngreat, let's get started!" << endl;
//if yes, the temp. program begins asking user for which task to proceed with
cout << "\n\nPlease select which type of conversion you would like to proceed with:" << endl;
cout << "a)Celsius to Fahrenheit \nb)Fahrenheit to Celsius \nc)I'm done" << endl;
cin >> n;
switch (n)
//first case executes the celsius to fahrenheit conversion module
//while loop that will repeat the program until I select option c
do
{
case 'a':
case 'A':
cout << "Let's get started!" << endl;
cout << "Please enter a celsius value." << endl;
cin >> celsius;
fahrenheit = ((9.0/5)*celsius) + 32;
cout << "the value you entered was " << celsius << endl;
cout << "that equals "<< fahrenheit << " degrees fahrenheit" << endl;
break;
//second case executes the fahrenheit to celsius conversion module
case 'b':
case 'B':
cout << "Let's get started!" << endl;
cout << "Please enter a fahrenheit value." << endl;
cin >> fahrenheit;
celsius = (5.0/9)*(fahrenheit - 32);
cout << "the value you entered was" << fahrenheit << endl;
cout << "that equals "<< fahrenheit << "celsius" << endl;
cout << "thank you for using the ULTRACONVERTOR 3000" << endl;
}
while ( n!= c)
cout << "thank you for using the ULTRACONVERTOR 3000" << endl;
//if not, the program identifies their answer as a no and the program ends
break;
case 'n':
case 'N':
cout << " too bad." << endl;
break;
default:
cout << "too bad" << endl;
break;
}
//fin
system ("PAUSE");
}
great, let's get started!
Please select which type of conversion you would like to proceed with:
a)Celsius to Fahrenheit
b)Fahrenheit to Celsius
c)I'm done
a
Let's get started!
Please enter a celsius value.
100
the value you entered was 100
that equals 212 degrees fahrenheit
thank you for using the ULTRACONVERTOR 3000
Press any key to continue . . .
Originally posted by: GhettoFob
you need to get the next char somewhere in the loop
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main()
{
double celsius;
double fahrenheit;
char m ;
char n;
//program introduction. Asks for confirmation to continue
cout << "WELCOME TO THE ULTRACONVERTOR 3000, YOUR SOURCE FOR TEMPERATURE CONVERSION," << endl;
cout << "FUFILLING ALL YOUR TEMPERATRUE NEED SINCE 1955" << endl;
cout << "\nWOULD YOU LIKE ME TO CONVERT TEMPERATURES TODAY?" << endl;
cout << "TYPE YES OR NO TO CONTINUE" << endl;
cin >> m;
//decides whether they typed yes or no by simply checking the first letter
switch( m ) {
case 'y':
case 'Y':
cout << "\n\n\ngreat, let's get started!" << endl;
//if yes, the temp. program begins asking user for which task to proceed with
//while loop that will repeat the program until I select option c
do
{
//first case executes the celsius to fahrenheit conversion module
cout << "\n\nPlease select which type of conversion you would like to proceed with:" << endl;
cout << "a)Celsius to Fahrenheit \nb)Fahrenheit to Celsius \nc)I'm done" << endl;
cin >> n;
switch (n)
case 'a':
case 'A':
cout << "Let's get started!" << endl;
cout << "Please enter a celsius value." << endl;
cin >> celsius;
fahrenheit = ((9.0/5)*celsius) + 32;
cout << "the value you entered was " << celsius << endl;
cout << "that equals "<< fahrenheit << " degrees fahrenheit" << endl;
break;
//second case executes the fahrenheit to celsius conversion module
case 'b':
case 'B':
cout << "Let's get started!" << endl;
cout << "Please enter a fahrenheit value." << endl;
cin >> fahrenheit;
celsius = (5.0/9)*(fahrenheit - 32);
cout << "the value you entered was" << fahrenheit << endl;
cout << "that equals "<< fahrenheit << "celsius" << endl;
cout << "thank you for using the ULTRACONVERTOR 3000" << endl;
}
while ( n!= 'c');
cout << "thank you for using the ULTRACONVERTOR 3000" << endl;
//if not, the program identifies their answer as a no and the program ends
break;
case 'n':
case 'N':
cout << " too bad." << endl;
break;
default:
cout << "too bad" << endl;
break;
}
//fin
system ("PAUSE");
}
Originally posted by: Goosemaster
WOOOOOOOOOOOOOOOOOOHOOOOOOOOOOOOO!
I WUV YOU GUYS SO MUCH
Now to add an array of sorts:evil:
Originally posted by: SilentZero
Originally posted by: Goosemaster
WOOOOOOOOOOOOOOOOOOHOOOOOOOOOOOOO!
I WUV YOU GUYS SO MUCH
Now to add an array of sorts:evil:
LMAO!