Kurs:Wirtschaftsinformatik WS08 09 PROGRAMMIERUNG/Code-Rubrik

Eingabemethoden vom Keyboard

Bearbeiten
import java.util.Scanner;
static int EingabeInt()
{         Scanner s = new Scanner(System.in); 
        int value = s.nextInt();
         return value;
 }          

static double EingabeDouble() 
{       
  Scanner s = new Scanner(System.in);  
       double value = s.nextDouble();   
      return value;
 }         

 static String EingabeString()
 {         Scanner s = new Scanner(System.in); 
        return s.next(); 
}  

static int Eingabe()
 {     
 // JDK 1.2 kompatibel, ohne Scanner...  
String s = "";  int f = 0; 
  java.io.BufferedReader d =      new java.io.BufferedReader(         new java.io.InputStreamReader(System.in));   

try { s = d.readLine();}   
catch (java.io.IOException e) { }

   try  { f = Integer.parseInt(s); } 
  catch (NumberFormatException e)  
 { System.out.println(        "String Conversion to int failed" + e); } 
  return f;
 }