HIho!
Also ich habe hier einen kleinen test code, mit dem ich übe... dabei stosse ich auch das problem, dass das System.in.read() nicht den Wert zurück gibt den ich eingeben will, sondern die Zahl 10. KA woher 10 kommt... also das System.in.read() wartet auch nicht auf eine Eingabe von mir.
gruss
gEry
Also ich habe hier einen kleinen test code, mit dem ich übe... dabei stosse ich auch das problem, dass das System.in.read() nicht den Wert zurück gibt den ich eingeben will, sondern die Zahl 10. KA woher 10 kommt... also das System.in.read() wartet auch nicht auf eine Eingabe von mir.
Code:
/*
public class test_class
{
public static void main(String[] args) throws IOException
{
System.out.println("\n\n\n-=Jav0r=-\nWelcome to my \"Learn toolz\"\nStarted@20.08.05");
System.out.println("Choose one of the following options:\n");
System.out.println("1. Hello World()\n");
System.out.println("2. f2c()\n");
char value = (char)System.in.read();
test_class funtions = new test_class();
switch(value)
{
case '1': funtions.Hello_World();
break;
case '2': funtions.f2c();
break;
default: System.out.println("Wrong value!");
}
System.out.println("\nByeBye, hope to see you later!\n");
}
void Hello_World()
{
System.out.println("\nHello World\n");
}
void f2c() throws IOException
{
System.out.println("\nWelcome to f2c()\n");
System.out.println("Bitte geben Sie den gewuenschten Wert in Fahrenheit ein:\n");
int fahr = (int)System.in.read(); // Hier ist der Fehler!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
int celsius = 5 * (fahr - 32) / 9;
System.out.println("\n" + fahr + " Fahrenheit sind ca. " + celsius + " Celsius\n");
}
}
gruss
gEry