Advertisement
Guest User

3_39

a guest
May 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1. package listatres;
  2. import java.util.Scanner;
  3. public class L3_39 {
  4.     public static void main (String[]args){
  5.     Scanner in = new Scanner(System.in);
  6.     int f = 28;
  7.     int dias = 0;
  8.     System.out.print("Informe o ano: ");
  9.     int ano = in.nextInt();
  10.     System.out.print("Informe o mes: ");
  11.     int mes = in.nextInt();
  12.     int a, j, s, n;
  13.     a = 30;
  14.     j = 30;
  15.     s = 30;
  16.     n = 30;
  17.         if (ano >= 1000 && ano <= 9999){
  18.             if (((ano%10/1*10)+(ano%100/10*1)) == 00) {
  19.                 if(ano%100 == 0 && ano%400 == 0){
  20.                 f++;
  21.                 }
  22.             } else {
  23.                 if (ano%4 == 0){
  24.                 f++;  
  25.                 }
  26.             }
  27.         }        
  28.        
  29.         if (mes >= 01 && mes <= 12) {
  30.             switch (mes){
  31.             case (1):
  32.                 dias = 31;
  33.                 break;
  34.             case (2):
  35.                 dias = 31 + f;
  36.                 break;
  37.             case (3):
  38.                 dias = 31*2 + f;
  39.                 break;
  40.             case (4):
  41.                 dias = 31*2 + f + a;
  42.                 break;
  43.             case (5):
  44.                 dias = 31*3 + f + a;
  45.                 break;
  46.             case (6):
  47.                 dias = 31*3 + f + a + j;
  48.                 break;
  49.             case (7):
  50.                 dias = 31*4 + f + a + j;
  51.                 break;
  52.             case (8):
  53.                 dias = 31*5 + f + a + j;
  54.                 break;
  55.             case (9):
  56.                 dias = 31*5 + f + a + j + s;
  57.                 break;
  58.             case (10):
  59.                 dias = 31*6 + f + a + j + s;
  60.                 break;
  61.             case (11):
  62.                 dias = 31*6 + f + a + j + s + n;
  63.                 break;
  64.             case (12):
  65.                 dias = 31*7 + f + a + j + s + n;
  66.                 break;
  67.             }        
  68.         }
  69.     System.out.println("O total de dias é: " + dias);    
  70.     }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement