Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package listatres;
- import java.util.Scanner;
- public class L3_39 {
- public static void main (String[]args){
- Scanner in = new Scanner(System.in);
- int f = 28;
- int dias = 0;
- System.out.print("Informe o ano: ");
- int ano = in.nextInt();
- System.out.print("Informe o mes: ");
- int mes = in.nextInt();
- int a, j, s, n;
- a = 30;
- j = 30;
- s = 30;
- n = 30;
- if (ano >= 1000 && ano <= 9999){
- if (((ano%10/1*10)+(ano%100/10*1)) == 00) {
- if(ano%100 == 0 && ano%400 == 0){
- f++;
- }
- } else {
- if (ano%4 == 0){
- f++;
- }
- }
- }
- if (mes >= 01 && mes <= 12) {
- switch (mes){
- case (1):
- dias = 31;
- break;
- case (2):
- dias = 31 + f;
- break;
- case (3):
- dias = 31*2 + f;
- break;
- case (4):
- dias = 31*2 + f + a;
- break;
- case (5):
- dias = 31*3 + f + a;
- break;
- case (6):
- dias = 31*3 + f + a + j;
- break;
- case (7):
- dias = 31*4 + f + a + j;
- break;
- case (8):
- dias = 31*5 + f + a + j;
- break;
- case (9):
- dias = 31*5 + f + a + j + s;
- break;
- case (10):
- dias = 31*6 + f + a + j + s;
- break;
- case (11):
- dias = 31*6 + f + a + j + s + n;
- break;
- case (12):
- dias = 31*7 + f + a + j + s + n;
- break;
- }
- }
- System.out.println("O total de dias é: " + dias);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement