Advertisement
CR7CR7

FirstAdd

Sep 24th, 2022
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class F12 {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner scanner = new Scanner(System.in);
  8.         String input = scanner.nextLine();  ;
  9.  
  10.         while (!(input.equals("END"))){
  11.             if(input.matches("([-+]?)[0-9]{0,}"))
  12.             {
  13.                 System.out.printf("%s is integer type\n", input);
  14.             }
  15.              else if (input.matches("([-+]?)[0-9]{0,}\\.([0-9]{0,})?"))
  16.             {
  17.                 System.out.printf("%s is floating point type\n", input);
  18.             }
  19.           else   if(input.length() == 1){
  20.                        System.out.printf("%s is character type\n", input);
  21.             }     else if (input.equalsIgnoreCase("true")|| input.equalsIgnoreCase("false")){
  22.                 System.out.printf("%s is boolean type\n", input);
  23.             }     else {
  24.                        System.out.printf("%s is string type\n", input);
  25.             }
  26.                     input = scanner.nextLine();
  27.         }
  28.             }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement