Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Solving {
- public static void main(String[] args) {
- Scanner read = new Scanner(System.in);
- String input;
- while (!"END".equals(input=read.nextLine())){
- if (checkInteger(input)){
- System.out.println(input+" is integer type");
- }else if (checkDouble(input)){
- System.out.println(input+" is floating point type");
- } else if (input.length()==1){
- System.out.println(input+" is character type");
- }else if (input.equalsIgnoreCase("true")||input.equalsIgnoreCase("false")){
- System.out.println(input+" is boolean type");
- }else {
- System.out.println(input+" is string type");
- }
- }
- }
- private static boolean checkDouble(String input) {
- try {
- Double.parseDouble(input);
- return true;
- }catch (Exception e){
- return false;
- }
- }
- private static boolean checkInteger(String input){
- try {
- Integer.parseInt(input);
- return true;
- }catch (NumberFormatException ex){
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement