-
March 19th, 2009, 10:58 AM
#1
Need Help w/While Loop & Switch
Hi All,
This is my first post here as I am just starting to teach mself programming. I am trying to write a simple program that changes Fahrenheit to Celcius and vice-versa.
I am having trouble with the loop, I can't seem to get out of it even once a selection has been made. As I am totally new to this, I may be going about it the wrong way but I have posted the code below. I am using the Dev-C++ IDE. All help greatly appreciated and any explanation to what I have done wrong would be really helpful too. Thank you in advance.
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleTitle("Tester");
int blank;
float Temperature;
char Conversion;
cout << "Enter Temperature: \t";
cin >> Temperature;
while (Temperature
{
cout << "Convert to Celcius or Fahrenheit <C/F>:";
cin >> Conversion;
switch (Conversion)
{//start switch
case 'C':
case 'c':{
cout << "Temperature is equal to " << (((Temperature - 32) * 5) / 9);
break;
}
case 'F':
case 'f':{
cout << "Temperature is equal to " << (((9 * Temperature)/ 5) + 32);
break;
}
default:{
cout << "INVALID";
}
}//end switch
}//end while
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|