Podstawowe wyjście
Lekcja 8 z 10 w kursie Konwerter temperatur w C++ w Coddy.
Teraz mamy już wszystkie konwertery! Stwórzmy interfejs użytkownika (funkcję główną), aby użytkownik tego programu mógł z łatwością korzystać z konwertera temperatury.
Wyzwanie
ŁatwyDodaj funkcję główną do swojego kodu (poniżej wszystkich funkcji konwertujących). Wewnątrz funkcji wyświetl następujące elementy:
Temperature Converter
1. Celsius to Fahrenheit
2. Celsius to Kelvin
3. Fahrenheit to Celsius
4. Fahrenheit to Kelvin
5. Kelvin to Celsius
6. Kelvin to FahrenheitSpróbuj swoich sił
float celsiusToFahrenheit(float celsius) {
return (celsius * 9.0 / 5.0) + 32.0;
}
double celsiusToKelvin(double celsius) {
return celsius + 273.15;
}
double fahrenheitToCelsius(double fahrenheit) {
return (fahrenheit - 32.0) * 5.0 / 9.0;
}
double fahrenheitToKelvin(double fahrenheit) {
return (fahrenheit + 459.67) * 5.0 / 9.0;
}
double kelvinToCelsius(double kelvin) {
return kelvin - 273.15;
}
double kelvinToFahrenheit(double kelvin) {
return kelvin * 9.0 / 5.0 - 459.67;
}
Wszystkie lekcje w sekcji Konwerter temperatur w C++
Poćwicz samodzielnie: Kompilator C++ online