Search code snippets, questions, articles...

metodo que te dice si un numero es par

import java.util.Scanner;

public class App {

    public static void par(int num) {
        if (num % 2 == 0) {
            System.out.println(num + " es par.");
        } // if
        else {
            System.out.println(num + " no es par.");
        } // else
    } // metodo mayor o menor que cero

    public static void main(String[] args) {
        Scanner read = new Scanner(System.in);
        int num = 1;
        while (num != 0) {
            System.out.print("Introduce el número: ");
            num = read.nextInt(); // read num
            if (num == 0) {
                System.out.println("Fin del programa.");
                break;
            } // if es cero
            par(num);
        } // while no es cerof

    } // main

}
Was this helpful?
0 Comments