Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String test = scanner.nextLine();
- while (!test.equals("END")) {
- try {
- Integer.parseInt(test);
- System.out.printf("%s is integer type%n", test);
- test = scanner.nextLine();
- continue;
- } catch (Exception ignore) {
- }
- try {
- Double.parseDouble(test);
- System.out.printf("%s is floating point type%n", test);
- test = scanner.nextLine();
- continue;
- } catch (Exception ignore) {
- }
- if (test.equalsIgnoreCase("true") || test.equalsIgnoreCase("false")) {
- System.out.printf("%s is boolean type%n", test);
- } else if (test.length() == 1 && (test.charAt(0) < 48 || test.charAt(0) > 57)) {
- System.out.printf("%s is character type%n", test);
- } else {
- System.out.printf("%s is string type%n", test);
- }
- test = scanner.nextLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement