|
From: <bis...@bt...> - 2000-12-21 09:39:41
|
Try:
cout << "Enter your choice: ";
cin >> choice;
- Biswa.
> -----Original Message-----
> From: The Jay Man [mailto:ja...@ya...]
> Sent: 21 December 2000 01:14
> To: dev...@li...
> Subject: [Dev-C++] I'm Stumped :(
>
>
> I have here some code for a small practice program I wrote. I
> have been
> looking ive the code for about a week now and cannot figure out why I
> get the following error: "Project1 caused an error in PROJECT1.EXE..."
> What is wrong with the code or my computer? Here is the code:
>
> #include <iostream.h>
>
> float fer;
> float cel;
> float kel;
> int choice;
> float fc()
> {
> float cel;
> cel = ((fer -32)*5)/9;
> return cel;
> }
> float fk()
> {
> float kel;
> kel = ((fer -32)*5)/9 + 273;
> return kel;
> }
> float cf()
> {
> float fer;
> fer = (cel * 9)/5 + 32;
> return fer;
> }
> float ck()
> {
> float kel;
> kel = cel + 273;
> return kel;
> }
> float kf()
> {
> float fer;
> fer = (((kel - 273)-32)*5)/9;
> return fer;
> }
> float kc()
> {
> float cel;
> cel = 273 - cel;
> return cel;
> }
> int main()
> {
>
> cout << "1: Fahrenheight to Celsius\n";
> cout << "2: Fahrenheight to Kelvin\n";
> cout << "3: Celsius to Fahrenheight\n";
> cout << "4: Celsius to Kelvin\n";
> cout << "5: Kelvin to Fahrenheight\n";
> cout << "6: Kelvin to Celsius\n";
> cout << "7: Exit";
> cin >> "Enter your choice" >> choice;
>
> switch (choice)
> {
> case 1: fc();
> cout << fer << " degrees Fahrenheight = " << cel <<
> "Degrees Celsius";
> break;
> case 2: fk();
> cout << fer << " degrees Fahrenheight = " << kel <<
> "Degrees Kelvin";
> break;
> case 3: cf();
> cout << cel << " degrees Celsius = " << fer <<
> "Degrees
> Fahrenheight";
> break;
> case 4: ck();
> cout << cel << " degrees Celsius = " << kel <<
> "Degrees
> Kelvin";
> break;
> case 5: kf();
> cout << kel << " degrees Kelvin = " << fer <<
> "Degrees
> Fahrenheight";
> break;
> case 6: kc();
> cout << kel << " degrees Kelvin = " << cel <<
> "Degrees
> Celsius";
> break;
> case 7:
> return 0;
> default:
> cout << "Invalid entry, exiting";
> }
>
> return 0;
> }
>
> P.S. It DOES compile sucessfully and will run until "cin >>
> "Enter your
> choice"; Thank you for your time,
>
> The Jay Man
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Shopping - Thousands of Stores. Millions of Products.
> http://shopping.yahoo.com/
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users
>
|