Shavit

Char or Number

Oct 20th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class CharOrNumber {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Scanner in = new Scanner (System.in);
  12.        
  13.         char ch;
  14.        
  15.         System.out.println("Enter your character:");
  16.             ch = in.next().charAt(0);
  17.        
  18.         System.out.println((ch >= '0' && ch <= '9') ? "This is a number" : "This is not a number");
  19.        
  20.         in.close();
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment