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; }
}
}
}
}
}