rendered paste body#include <iostream>
using namespace std;
void menus(); // function prototype
int main() {
int menu, choice;
float metresSecond, kilometresHour, tempF, tempC;
float usd, gbp, euro, oneGbpToEuro, oneGbpToUsd, valueOne, valueTwo, randomRate;
cout << "For conversions involving speed press 1" << endl;
cout << "For conversions involving temperature press 2" << endl;
cout << "For conversions involving money press 3" << endl;
cin >> menu;
switch(menu) {
case 1:
system("cls");
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: " << kilometresHour << "km/h" << endl;
menus();
break;
case 2:
cout << "Please enter your value in kmh^-1" << endl;
cin >> kilometresHour;
metresSecond = ((kilometresHour * 1000)/3600);
cout << "Your speed is: " << metresSecond << "m/s" << endl;
menus();
break;
default:
cout<<"This isn't a valid option.";
menus();
break;
}
break;
case 2:
system("cls");
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: " << tempF << "Degrees Fahrenheit" << endl;
menus();
break;
case 2:
cout << "Please enter your value in Fahrenheit" << endl;
cin >> tempF;
tempC = ((tempF - 32) * 5) / 9;
cout << "Your value is; " << tempC << "Degrees Celcius" << endl;
menus();
break;
default:
cout<<"This isn't a valid option.";
menus();
break;
}
case 3:
system("cls");
cout << "For GBP to USD press 1" << endl;
cout << "For USD to GBP press 2" << endl;
cout << "For GBP to Euro press 3" << endl;
cout << "For Euro to GBP press 4" << endl;
cout << "For OTHER conversion press 5" << endl;
cin >> choice;
switch (choice) {
case 1:
cout << "Please enter the conversion rate for 1 GBP to USD (eg 1.92)" << endl;
cin >> oneGbpToUsd;
cout << "Please enter your value in GBP" << endl;
cin >> gbp;
usd = (gbp * oneGbpToUsd);
cout << "Your answer is " << usd << "Dollars" << endl;
menus();
break;
case 2:
cout << "Please enter the conversion rate for 1 GBP to USD (eg 1.92)" << endl;
cin >> oneGbpToUsd;
cout << "Please enter your value in USD" << endl;
cin >> usd;
gbp = (usd / oneGbpToUsd);
cout << "Your answer is " << gbp << "Pounds" << endl;
menus();
break;
case 3:
cout << "Please enter the conversion rate for 1 GBP to Euros (eg 1.43)" << endl;
cin >> oneGbpToEuro;
cout << "Please enter your value in GBP" << endl;
cin >> gbp;
euro = (gbp * oneGbpToEuro);
cout << "Your answer is " << euro << "Euros" << endl;
menus();
break;
case 4:
cout << "Please enter the conversion rate for 1 GBP to Euros (eg 1.43" << endl;
cin >> oneGbpToEuro;
cout << "Please enter your value in GBP" << endl;
cin >> euro;
gbp = (euro / oneGbpToEuro);
cout << "Your answer is " << gbp << "Pounds" << endl;
menus ();
break;
case 5:
cout << "Please enter your conversion for Value 1 to Value 2 rate" << endl;
cin >> randomRate;
cout << "Please enter your first value" << endl;
cin >> valueOne;
valueTwo = (valueOne * randomRate);
cout << "Your answer is" << valueTwo << endl;
menus();
break;
default:
cout<<"This isn't a valid option.";
menus();
break;
}
break;
}
return 0;
}
void menus() {
char exitChoice;
cout << "\nPress Y to begin menu again, press N to exit\n";
cin >> exitChoice;
switch (exitChoice) {
case 'y':
system("cls");
main();
break;
case 'n':
exit(0);
break;
default:
cout << "That isn't a correct option\n\n";
menus();
break;
}
}