Reading Terminal Or DOS Input Using SavitchIn Java Class




Class for simple console input. A class designed primarily for simple keyboard input of the form one input value per line. If the user enters an improper input, i.e., an input of the wrong type or a blank line, then the user is prompted to reenter the input and given a brief explanation of what is required. Also includes some additional methods to input single numbers, words, and characters, without going to the next line.

Usage:
01public class Usage {
02  public static void main(String [] args) {
03    // for string input
04    String s;
05    System.out.print("Enter a string value: ");
06    s = SavitchIn.readLine();
07    System.out.println(s);
08 
09    // for integer input
10    int i;
11    System.out.print("Enter an integer value: ");
12    i = SavitchIn.readInt();
13    System.out.println(i);
14 
15    // for double input
16    double d;
17    System.out.print("Enter a double value: ");
18    d = SavitchIn.readDouble();
19    System.out.println(d);
20 
21    // for char input
22    char c;
23    System.out.print("Enter a char value: ");
24    c = SavitchIn.readChar();
25    System.out.println(c);
26 
27  }
28}

Penulis : Unknown ~ Sebuah blog yang menyediakan berbagai macam informasi

Artikel Reading Terminal Or DOS Input Using SavitchIn Java Class ini dipublish oleh Unknown pada hari . Semoga artikel ini dapat bermanfaat.Terimakasih atas kunjungan Anda silahkan tinggalkan komentar.sudah ada 0 komentar: di postingan Reading Terminal Or DOS Input Using SavitchIn Java Class
 

0 comments:

Post a Comment

Leave Me a Comment Below. Thanks :)