Guest User

Untitled

a guest
Jun 10th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. package p01_Intro_To_Java_Lab;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class test2 {
  6.     public static void main(String[] args)  {
  7.  
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         int day = Integer.parseInt(scanner.nextLine());
  11.         int month = Integer.parseInt(scanner.nextLine());
  12.  
  13.         int daysInMonth = 31;
  14.  
  15.         if(month == 2) {
  16.             daysInMonth = 28;
  17.         }
  18.  
  19.         if (month == 4 || month == 6 || month == 9 || month == 11) {
  20.             daysInMonth = 30;
  21.         }
  22.  
  23.         day +=5;
  24.  
  25.         if (day > daysInMonth) {
  26.             day -= daysInMonth;
  27.             month++;
  28.             if(month > 12) {
  29.                 month = 1;
  30.             }
  31.         }
  32.         System.out.printf("%d.%02d", day, month);
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment