repl.it
@bikey/

JavaString02

Java

No description

fork
loading
Files
  • Main.java
  • jdt.ls-java-project
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String input;

    do {
      System.out.print("INPUT:");
      input = scan.nextLine();
      if(input.isEmpty()) { break; }
      else if(input.equals("clear")) {
        System.out.print("\033[H\033[2J");
        continue;
      }

      if(input.contains(" ")) {
        String msg = String.format("String:%s", input);
        System.out.println(msg);
      } else if(input.contains(".")) {
        double d = Double.parseDouble(input);
        String msg = String.format("Double:%8.2f", d);
        System.out.println(msg);
      } else {
        int n = Integer.parseInt(input);
        String msg = String.format("Int:%011d", n);
        System.out.println(msg);
      }
    } while(true);
    
  }
}
?