Du hast wahrscheinlich schon oft elektronische Umwandler oder Programme verwendet, um eine Menge in einer Einheit in eine Menge einer anderen Einheit umzurechnen. Zum Beispiel Dollar in Euro oder Meilen in Kilometer. Jetzt ist es an der Zeit, dass wir ein solches Tool programmieren. Konkret werden wir ein Programm schreiben, das eine Temperatur von Grad Celsius in Grad Fahrenheit umwandelt.
Unser erster Umwandler!
- 7
Gesperrt
Kommentare (14)
- Beliebt
- Neu
- Alt
Du musst angemeldet sein, um einen Kommentar schreiben zu können
Yusuf et Turki
27 Oktober 2022, 06:07
In Java intiger / intiger = intiger
that means, the result from 9/5 = 1. But we need something double.
So because of that we should calculate like that 9/5.0 = 1.8 . In this way we get the right answer.
0
Daniel Bergmann
11 Oktober 2022, 15:06
ihr müßt statt (9/5) -> 1.8 eingeben. Dann kommt die korrekte 105 statt 73 raus ;-)
0
Claudia Theiling
24 Juni 2020, 21:06
Hello, I had the same problem. Only when I declared TF and TC as double the result was correct. But I can’t explain why!
If I multiply an Integer with a double the result should be a double, shoudn’t it?
0
Saskia Schmidt
2 März 2020, 13:50
Brauch dringend Hilfe, bis auf den letztn Punkt funktioniert alles. Aber sobald ich double Fahrenheit verwende ist das Programm falsch. Warum? Schließlich heißt es, dass Fahrenheit als double und nicht als integer genutzt werden muss.
0
Alex Vypirailenko Java Developer bei Toshiba Global Comme
4 März 2020, 08:51
Please use the Help section, if you are having issues with a particular task. Without the code, no one can see what the problem is and therefore no one can help.
0
Muhamed
22 Februar 2020, 21:46
"double Fahrenheit;" muss hier genutzt werden - should be used here
0
German Squiddlet
27 Januar 2020, 00:25
public static double celsiusInFahrenheitUmwandeln(int celsius) {
return (celsius*9/5)+32;
}
this is correct. but gets refused.
0
Martin Eichler
3 Februar 2020, 03:51
Did you declare the fahrenheit variable as 'double' instead of 'int'?
0
Tilman Drößler
7 März 2020, 11:44
I could imagine you have an logical problem.
It should work if you put 1.8 instead the 9/5. Or you can change the funktion. return(celsius*(9/5))+32;
+1
Fabian GU
10 März 2020, 10:55
I had the same problem, the program returned 105 instead of 105.8...
You have to add an decimalpoint after --> 5 = 5.0 it should return the correct value.
0
BernhardH
23 Dezember 2021, 09:38
Because there are only int values in the formular it wil calculate a int result, so the ".8" is lost, even when it returns a double.
When you use 1.8 instead of 9/5 it will work
0
Sebastian Meyer
14 November 2019, 17:18
why is the last point not correct?
0
Roman
15 November 2019, 06:35
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at codegym.cc/help.
0
Olligame
14 Januar 2020, 12:25
you have to incorporate the value from above into the method and assign the value
0