I know this problem has been there before but I still need help. I have found an old task and have been at it for 5 hours but can't find the solution. Does someone have some advice for me? The task is to create an math formula which allows to decide between 3 different formula without any kind of "switch, if-else or other operators" Sooo goal is it to just cin a number; decide with cin 1, 2 or 3 between Celsius to Fahrenheit, meters in foot or € in $ and gettin a result.
The formulas are:
- Celsius degrees to Fahrenheit = x * 1.8 + 32
- meters to feet = x * 3.2808
- euro to US dollar = x * 1.2957
I am not allowed to use if, else, bool, == etc. Only +, -, , *, =, cout, cin and the other basic things like data type and variables.
#include <iostream>
using namespace std;
int main()
{
double eingabe;
int auswahl = 0;
double ergebnis;
//zahleneingabe
cout << "Ihre Eingabe: ? " << endl;
cin >> eingabe;
cout << "Ihre Eingabe: " << eingabe << endl;
system("PAUSE");
//abfragenausgabe der umrechnungsart
cout << "Ihre Auswahl der Umwandlung: " << endl;
cout << "1 - Celsius in Fahrenheit" << endl;
cout << "2 - Meter in Fuss" << endl;
cout << "3 - Euro in US Dollar " << endl;
cin >> auswahl;
cout << "Ihr Ergebnis ist: " << ergebnis << endl;
system("PAUSE");
}