ABaDy1996

labExam

Oct 22nd, 2020
1,328
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class DriverMain {
  2.     public static void main(String[] args) {
  3.         Scanner input = new Scanner(System.in);
  4.         System.out.printf("Please enter today's date%n\t day: %n");
  5.         int day = input.nextInt();
  6.         while(day<1 || day>30){
  7.             System.out.printf("Incorrect, please enter again: %n");
  8.             day = input.nextInt();
  9.         }
  10.         System.out.println("\t month: ");
  11.         int month = input.nextInt();
  12.         while(month<1 || month>12){
  13.             System.out.printf("Incorrect, please enter again: %n");
  14.             month = input.nextInt();
  15.         }
  16.         System.out.println("\t year: ");
  17.         int year = input.nextInt();
  18.         while(year<1900 || year>2100){
  19.             System.out.printf("Incorrect, please enter again: %n");
  20.             year = input.nextInt();
  21.         }
  22.         System.out.println("Enter the number of next dates you want to print: ");
  23.         int count = input.nextInt();
  24.         for(int counter = 1;counter<=count;counter++){
  25.             if(day+1>30){
  26.                 if(month+1>12){
  27.                     year+=1;
  28.                     month=1;
  29.                 }else month+=1;
  30.                 day=1;
  31.             }else{
  32.                 day+=1;
  33.             }
  34.             System.out.printf("Day %d date %d - %d - %d%n",counter,day,month,year);
  35.         }
  36.     }
  37. }
  38.  
RAW Paste Data