Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Locale;
- import java.util.Scanner;
- public class InputValue {
- //Declaración de Scanner
- public static Scanner sc = new Scanner(System.in);
- public static void main(String[] args) {
- Double number = 0.0;
- try {
- System.out.print("Introduce un número: ");
- sc.useLocale(Locale.US); //It's a dot .
- number = sc.nextDouble();
- if(number%2==0) {
- System.out.println("\t> " + number + " es par");
- } else {
- System.out.println("\t> " + number + " es impar");
- }
- }catch (Exception e) {
- System.err.println("Error, no has introducido un número");
- }
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement