Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package O2DataTypesAndVar.MoreExercise;
- import java.util.Scanner;
- public class Ex01DataTypeFinderV2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- while (!scanner.hasNext("END")) {
- if (scanner.hasNextInt()) {
- System.out.println(scanner.nextInt() + " is integer type");
- } else if (scanner.hasNextFloat()) {
- System.out.println(scanner.nextFloat() + " is floating point type");
- } else if (scanner.hasNextBoolean()) {
- System.out.println(scanner.nextBoolean() + " is boolean type");
- } else if (scanner.hasNext()) {
- String symbols = scanner.next();
- if (symbols.length() >= 2 ) {
- System.out.println(symbols + " is string type");
- } else {
- System.out.println(symbols + " is character type");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment