Question
Use the web to learn how to use the LocalDate Boolean methods isBefore(), isAfter(), and equals(). Use your knowledge to write a program that prompts
Use the web to learn how to use the LocalDate Boolean methods isBefore(), isAfter(), and equals(). Use your knowledge to write a program that prompts a user for a month, day, and year, and then displays a message specifying whether the entered day is in the past, is today(the current date), or is in the future.
Given code:
import java.util.*;
import java.time.*;
public class PastPresentFuture2
{
public static void main (String args[])
{
LocalDate today = LocalDate.now();
LocalDate enteredDate;
int mo, da, yr;
int todayMo, todayDa, todayYr;
Scanner input = new Scanner(System.in);
System.out.print("Enter a month >> ");
mo = input.nextInt();
System.out.print("Enter a day >> ");
da = input.nextInt();
System.out.print("Enter a year (four digits) >> ");
yr = input.nextInt();
// Write your code here
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started