Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DateAfter5Days {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int day = Integer.parseInt(scanner.nextLine());
- int month = Integer.parseInt(scanner.nextLine());
- int daysInMonth = 31;
- if( month == 2) {
- daysInMonth = 28;
- }
- if (month == 4 || month == 6 || month == 9 || month == 11) {
- daysInMonth = 30;
- }
- day +=5;
- if (day > daysInMonth) {
- day -= daysInMonth;
- }
- if (day > daysInMonth) {
- day -= daysInMonth;
- month++;
- if(month > 12) {
- month = 1;
- }
- }
- System.out.printf("%d.%02d", day, month);
- }
- }
Add Comment
Please, Sign In to add comment