Número de Años Bisiestos

download Número de Años Bisiestos

If you can't read please download the document

description

Número de años bisiestos entre dos años a ingresar. JAVA

Transcript of Número de Años Bisiestos

package nmerodeaosbisiestos;import javax.swing.JOptionPane;public class NmeroDeAosBisiestos { int a, b; void CargarAos(){ String sa = JOptionPane.showInputDialog("Ingrese algn ao");a = Integer.parseInt(sa);String sb = JOptionPane.showInputDialog("Ingrese otro ao");b = Integer.parseInt(sb); } void NmeroDeAosBisiestos(){ if(b > a){ for(int i = a; i < b + 1; i++){ if(i % 4 == 0 && i % 100 != 0){ System.out.print(i+"; "); } } } else{ for(int i = b; i < a + 1; i++){ if(i % 4 == 0 && i % 100 != 0){ System.out.print(i+"; "); } } } } public static void main(String[] args) { NmeroDeAosBisiestos objeto = new NmeroDeAosBisiestos(); objeto.CargarAos(); System.out.println("Los aos bisiestos entre los aos ingresados son:"); objeto.NmeroDeAosBisiestos(); }}