Programm zum Umrechnnen von Fahrenheit und Celsius in C++
#include
#include
using namespace std; int main() { double fahrenheit, celsius; int nachkomma; string what; /*Hier geht das eigentliche Programm los*/ cout << "Was wollen sie tun?\n [C]elsius zu Fahrenheit\n [F]ahrenheit zu Celsius\n umrechnen\n [B]eenden\n"; cin >> what; if (what == "f" or what == "F") { cout << "Temperatur in Fahrenheit: "; cin >> fahrenheit; celsius = (fahrenheit - 32) * 5.0 / 9.0; } else if (what == "c" or what == "C") { cout << "Temperatur in Celsius: "; cin >> celsius; fahrenheit = celsius / (5.0 / 9.0) + 32; } else if (what == "b" or what == "B") { return 0; } else { cout << "Falsche Eingabe"; return 0; } cout << "Anzahl an Nachkommastellen: "; cin >> nachkomma; /* Ausgabe */ cout.precision(nachkomma); cout << fixed << right; cout.width(7); cout << fahrenheit << " Grad Fahrenheit entsprechen "; cout.width(7); cout << celsius << " Grad Celsius"; return 0; }
Auch als Download:
Windows
Source