Hi,
habe folgendes Problem: Ich möchte bestimmte, gegebene Fahrenheit -Werte in Celsius berechnen und diese dann in double casten, was allerdings nicht klappt und zu einem Compile-Fehler führt.
Vielleicht hat jemand eine Idee?
|
Java Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
class Temperature {
public static int fahrenheit2celsius (int fahrenheit) {
int celsius = (5/9.0)*(fahrenheit -32.0);
}
public static void main(String[] args) {
System.out.println("fahrenheit=" + -50 + " celsius=" + fahrenheit2celsius(-50));
System.out.println("fahrenheit=" + 0 + " celsius=" + fahrenheit2celsius(0));
System.out.println("fahrenheit=" + 32 + " celsius=" + fahrenheit2celsius(32));
System.out.println("fahrenheit=" + 213 + " celsius=" + fahrenheit2celsius(213));
System.out.println("fahrenheit=" + 451 + " celsius=" + fahrenheit2celsius(451));
}
}
|
Danke!
chris