All pastes #281515 Raw Edit

Stuff

public text v1 · immutable
#281515 ·published 2006-12-16 21:33 UTC
rendered paste body
#include <iostream> 
using namespace std;
int main() {
    int menu, choice;
    int metresSecond, kilometresHour, tempF, tempC;
	
    cout << "For conversions involving speed press 1" << endl;
    cout << "For conversions involving temperature press 2" << endl;
    cin >> menu;
    switch(menu) {
    case 1:
         
         cout << "For ms^-1 to kmh^-1 press 1" << endl;
         cout << "For kmh^-1 to ms^-1 press 2" << endl;
         cin >> choice;   
         switch(choice) {
                            case 1:
                            cout << "Please enter your value in ms^-1" << endl;
                            cin >> metresSecond;
                            kilometresHour = ((metresSecond * 3600)/1000); 
                            cout << "Your speed is: ";
                            cout << kilometresHour;
                            cout << "km/h\n";
                            break;

                            case 2:
                            cout << "Please enter your value in kmh^-1" << endl;
                            cin >> kilometresHour;
                            metresSecond = ((kilometresHour * 1000)/3600);
                            cout << "Your speed is: ";
                            cout << metresSecond;
                            cout << "m/s\n";
                            break;

                            default:
                            cout<<"This isn't a valid option.";
                            return(-1);
                            break;
                            }
		 break;
         
    case 2:
         cout << "For Celcius to Fahrenheit press 1" << endl;
         cout << "For Fahrenheit to Celcius press 2" << endl;
         cin >> choice;
		 switch (choice) {
							case 1:
							cout << "Please enter your value in Celcius" << endl;
							cin >> tempC;
							tempF = ((tempC * 9) /5) + 32;
							cout << "Your value is: ";
							cout << tempF;
							cout << " Degrees Farenheit";
							break;
							case 2:
							cout << "Please enter your value in Fahrenheit" << endl;
							cin >> tempF;
							tempC = ((tempF - 32) * 5) / 9;
							cout << "Your value is; ";
							cout << tempC;
							cout << "Degrees Celcius";
							break;
		 }					
		break;         
    }
   	cin >> metresSecond;
    return 0;
}