Created
November 11, 2012 22:14
-
-
Save marioplumbarius/4056459 to your computer and use it in GitHub Desktop.
Programa em Java que informa se um dado ano é bissexto ou não
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Faça um programa que informe se um dado ano é bissexto ou não. | |
* Repira essa operação 15 vezes. | |
* | |
* Obs: um ano é bissexto se ele for divisível por 400 ou se ele for divisível por 4 e não por 100. | |
*/ | |
package cap14; | |
import java.util.Scanner; | |
public class Exercicio06 { | |
public static void main(String[] args){ | |
Scanner ent = new Scanner(System.in); | |
int ano; | |
System.out.println("Digite um ano para saber se é bissexto"); | |
ano = ent.nextInt(); | |
// se o ano for maior que 400 | |
if(ano % 400 == 0){ | |
System.out.println(ano + " é bissexto."); | |
// se o ano for menor que 400 | |
} else if((ano % 4 == 0) && (ano % 100 != 0)){ | |
System.out.println(ano + " é bissexto."); | |
} else{ | |
System.out.println(ano + " não é bissexto"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment