Class InOut

java.lang.Object
  extended by InOut

public class InOut
extends java.lang.Object

Support class for console input and output of numeric values.

Example for input:
 int age = InOut.readInt("Your age: ");

Example for output:
 System.out.println("price: " + InOut.format2(prize) + "Euro");
 System.out.println("percent: " + InOut.formatN(percent, 1) + " %");


Constructor Summary
InOut()
           
 
Method Summary
static java.lang.String format2(double d)
          Formats a double-value with 2 decimal digits.
static java.lang.String formatN(double d, int N)
          Formats a double-value with N decimal digits.
static boolean readBoolean(java.lang.String prompt)
          Reads a boolean-value from console.
static char readChar(java.lang.String prompt)
          Reads a char-value from console.
static double readDouble(java.lang.String prompt)
          Reads a double-value from console.
static float readFloat(java.lang.String prompt)
          Reads a float-value from console.
static int readInt(java.lang.String prompt)
          Reads an int-value from console.
static java.lang.String readln()
          Reads a string-value from console without prompt.
static long readLong(java.lang.String prompt)
          Reads a long-value from console.
static java.lang.String readString(java.lang.String prompt)
          Reads a string-value from console.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InOut

public InOut()
Method Detail

format2

public static java.lang.String format2(double d)
Formats a double-value with 2 decimal digits.


formatN

public static java.lang.String formatN(double d,
                                       int N)
Formats a double-value with N decimal digits.


readBoolean

public static boolean readBoolean(java.lang.String prompt)
Reads a boolean-value from console.


readChar

public static char readChar(java.lang.String prompt)
Reads a char-value from console.


readDouble

public static double readDouble(java.lang.String prompt)
Reads a double-value from console.


readFloat

public static float readFloat(java.lang.String prompt)
Reads a float-value from console.


readInt

public static int readInt(java.lang.String prompt)
Reads an int-value from console.


readLong

public static long readLong(java.lang.String prompt)
Reads a long-value from console.


readString

public static java.lang.String readString(java.lang.String prompt)
Reads a string-value from console.


readln

public static java.lang.String readln()
Reads a string-value from console without prompt. For use at the end of a console program.