-
Lenguaje
Java usando Scanner
-
Descripción
Pide un número muestra si es entero o decimal.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.util.Scanner;
public class NumeroEnteroODecimal {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double un_numero;
System.out.print("Ingresa el valor de un numero: ");
un_numero = in.nextDouble();
in.nextLine();
if(un_numero==Math.floor(un_numero))
System.out.println("Es entero");
else
System.out.println("Es decimal");
}
}
public class NumeroEnteroODecimal {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double un_numero;
System.out.print("Ingresa el valor de un numero: ");
un_numero = in.nextDouble();
in.nextLine();
if(un_numero==Math.floor(un_numero))
System.out.println("Es entero");
else
System.out.println("Es decimal");
}
}