You are not logged in.

  • Login

Dear visitor, welcome to Coder Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, December 6th 2006, 4:23pm

Fahrenheit in Celsius umwandeln

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

2

Wednesday, December 6th 2006, 5:11pm

Re: Fahrenheit in Celsius umwandeln

Thread kann geschlossen werden.

3

Wednesday, December 6th 2006, 10:07pm

Java Quellcode

1
2
3
public double fahrenheit2celsius (int fahrenheit) {
        return (5/9.0)*(fahrenheit -32.0);
}

Similar threads

Social bookmarks