dimanche 27 mars 2016

how to show a message in screen if the number is int or double in java?

im doing a homework of learning java from a university and i dont know how to do this im trying to put a message if the user enter a number like "11" or wherever show a message like "this number is integer: 11" but if i write in screen 22,4 show a message like "this number is decimal: 22,4"

we recently were seeing the use of "If , else, and boolean"

can u guys help me pls D:

regards

im working with this code

import java.util.Scanner ;

public class casa1 {
      public static void main (String[] args)
      {
         Scanner entrada;

         entrada = new Scanner(System.in); 

         float number=0;

         System.out.print("Enter a number: ");
         number=entrada.nextFloat();

         //heres when i dont know what to do for show a message if is int or double
         if(number==int){
         System.out.print("Your Number is decimal: ");
}
}

Aucun commentaire:

Enregistrer un commentaire