Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = "", dataType = "";
- while (true) {
- if(scanner.hasNextInt()) {
- dataType = "integer";
- input = scanner.nextLine();
- } else if (scanner.hasNextDouble()) {
- dataType = "floating point";
- input = scanner.nextLine();
- } else if (scanner.hasNextBoolean()) {
- dataType = "boolean";
- input = scanner.nextLine();
- } else {
- input = scanner.nextLine();
- if (input.equals("END")) {
- break;
- }
- dataType = input.length() == 1 ? "character" : "string";
- }
- System.out.printf("%s is %s type\n", input, dataType);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement