sidex15

decimal or integer java

Sep 19th, 2021 (edited)
788
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. public class MyClass {
  3.     public static void main(String args[]) {
  4.       Scanner myObj = new Scanner(System.in);
  5.       System.out.println("input a number: ");
  6.       double num = myObj.nextDouble();
  7.       if (num % 1 == 0){
  8.           System.out.println("This number is integer");
  9.       }
  10.       else{
  11.           System.out.println("this number is decimal");
  12.       }
  13.  
  14.      
  15.     }
  16. }
RAW Paste Data