Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created July 7, 2014 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/897f6a5f7ed61c7b5f0a to your computer and use it in GitHub Desktop.
Save Fhernd/897f6a5f7ed61c7b5f0a to your computer and use it in GitHub Desktop.
Programa para determinar la paridad de un número entero.
import java.util.Scanner;
// Declaración de clase
public class ParOImpar
{
// El método 'main' inicia la ejecución de la aplicación en Java
public static void main( String[] args )
{
// Variables
int numero;
// Instanciación de un objeto de clase 'Scanner'
Scanner entrada = new Scanner( System.in );
// Solicitud y obtención del número entero
System.out.print( "Digite un número entero: " );
numero = entrada.nextInt();
// Determinar si es par o impar
if( numero % 2 == 0 )
{
System.out.printf("\n%d es par.\n", numero );
}
if( numero % 2 != 0 )
{
System.out.printf("\n%d es impar.\n", numero );
}
// Salida
System.exit(0);
} // fin de main
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment