Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a program that asks a user for a date, month, day, year separately, and ou

ID: 3638580 • Letter: W

Question

write a program that asks a user for a date, month, day, year separately, and outputs the date of the next day.
don't forget leap year

this is the code i wrote cant someone help me complete it the program

import java.util.*;
public class Calender{
public static void main(String[] args){

int day, month, year, n;//declare the variables to be used for the program
Scanner in = new Scanner(System.in);



System.out.print("How many times you would like to check different dates ");// Asks the user for the number of times they would like to check dates
n = in.nextInt();//Input of how many time you want to find date
System.out.println();
for(int i=1; i<=n; i++);{//counter for the input

System.out.print("What is your date ");// Asks user for date you want to find the next date of
month = in.nextInt();// Input the month
System.out.print("/");
day = in.nextInt();//Input the day
System.out.print("/");
year = in.nextInt();//Input the day
System.out.println();}

System.out.print("The next date will be ");//Here will out put the next date of the entered date
System.out.print(month);
System.out.print("/");
System.out.print(day);
System.out.print("/");
System.out.println(year);

}
//This is to calculate the leapyear
public static boolean leapyear(int year){
if(year % 4==0)//The year is evenly divisible by 4
return true;
if(year % 100==0)//If the year can be evenly divided by 100, it is NOT a leap year, unless;
return false;
if(year % 400==0)//The year is also evenly divisible by 400. Then it is a leap year.
return true;
return true;// Year is a leap year
}
//Calculate the months and days of a year
public static void months_of_year(int year,int month,int day){
for (month=1; month<=12; month ++){//12 months is = to one year so the program will loop only 12 time according to the condition

if((month == 1)or(month == 3)or(month == 5)or(month == 7)or(month == 8)or(month == 10)or(month == 12))//This part will tell the which months have 31 day
for(day=1; day <= 31; day++){

if( (month == 4)||(month == 6)||(month == 9)||(month == 11) )//This part tells the program which months have 30 day
for(day = 1; day <= 30; day++){

if(month == 2);// This part will let the program know that feb has 29 only if it's a leap year other wise it will have 28 days
for(day = 1; day <= 29; day++){
year = leapyear;

if (year != leapyear)//if the year is not leap feb has 28 days
day = 28; }

}
}
}
}

}

Explanation / Answer

Hi, my friend here is the class date hope this will help u if u need more help message me PLEASE RATE public class Date { private static final int[] DAYS = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; private final int month; // month (between 1 and 12) private final int day; // day (between 1 and DAYS[month] private final int year; // year // do bounds-checking to ensure object represents a valid date public Date(int m, int d, int y) { if (!isValid(m, d, y)) throw new RuntimeException("Invalid date"); month = m; day = d; year = y; } // is the given date valid? private static boolean isValid(int m, int d, int y) { if (m < 1 || m > 12) return false; if (d < 1 || d > DAYS[m]) return false; if (m == 2 && d == 29 && !isLeapYear(y)) return false; return true; } // is y a leap year? private static boolean isLeapYear(int y) { if (y % 400 == 0) return true; if (y % 100 == 0) return false; return (y % 4 == 0); } // return the next Date public Date next() { if (isValid(month, day + 1, year)) return new Date(month, day + 1, year); else if (isValid(month + 1, 1, year)) return new Date(month + 1, 1, year); else return new Date(1, 1, year + 1); } // is this Date after b? public boolean isAfter(Date b) { return compareTo(b) > 0; } // is this Date a before b? public boolean isBefore(Date b) { return compareTo(b) < 0; } // comparison function between two dates public int compareTo(Date b) { if (year != b.year) return year - b.year; if (month != b.month) return month - b.month; return day - b.day; } // return a string representation of this date public String toString() { return month + "/" + day + "/" + year; } // sample client for testing public static void main(String[] args) { Date today = new Date(2, 25, 2004); System.out.println(today); for (int i = 0; i < 10; i++) { today = today.next(); System.out.println(today); } System.out.println(today.isAfter(today.next())); System.out.println(today.isAfter(today)); System.out.println(today.next().isAfter(today)); } }