UNA HERMOSA MOTO

UNA HERMOSA MOTO

sábado, 4 de abril de 2015

AÑO BISIESTO



AÑO BISIESTO

Determinaremos si un año es bisiesto. Un año es bisiesto siempre y cuando sea múltiplo de 4, por ejemplo 2000. En cambio los años múltiplos de 100 no son bisiestos, excepto si son también múltiplos de 400. 

Programando:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package añobisiesto1;
import java.util.Scanner;

/**
 *
 * @author abel montalvan
 */
public class Añobisiesto1 {

    /**
     * @param args the command line arguments
     */
 
public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       int x;
      System.out.println("Ingresar el año");
      x= sc.nextInt();
     if(x % 4 == 0 && x % 100 != 0 || x % 400 == 0)
     {System.out.println("El año "+x+" Sí es bisiesto ");}
     else
     {System.out.println("El año "+x+" No es bisiesto ");}
   
}
}

No hay comentarios:

Publicar un comentario