martes, 25 de junio de 2013

Solución clase 15 iCarnegie aprende a usar boolean


/**
 *
 */
package exercise15;
import java.util.Scanner;
/**
 * @author Chuy Juarez
 *
 */
public class Exercise15
 {
public static void main(String[] args) {
String ASK_YEAR = "Please enter a year:";
Scanner keyboard = new Scanner(System.in);
//Ask for a Year
System.out.println(ASK_YEAR);
System.out.println("Student's code goes here");
boolean variable=true;
if(variable==keyboard.hasNextInt())
{
int year=Integer.parseInt(keyboard.nextLine());
boolean testA=true;
boolean testB=true;
boolean testC=true;
if(testA==((year%4)==0)&&testB==((year%100)!=0))
{
System.out.println(year+" Is a leap year");
}
else
{
if(testA==((year%4)==0)&&testB==((year%100)==0)&&testC==((year%400)==0))
{
System.out.println(year+" Is a leap year");
}
else
{
System.out.println(year+" Is not a leap year");
}
}
}
else
{
System.out.println("Error digite un numero entero");
}
}
}

No hay comentarios :

Publicar un comentario