subject

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. import java. util.*;
import java. time. LocalDate;
public class PastPresentFuture2
{
public static void main(String args[])
{
int mo, da, yr;
LocalDate today=LocalDate. now();
System. out. println("Program to find if the given date is in past, present or future::");
Scanner input=new Scanner(System. in);
//taking inputs from console and storing them in three variables.
System. out. print("Enter month::");
mo=input. nextInt();
System. out. print("Enter day::");
da=input. nextInt();
System. out. print("Enter year::");
yr=input. nextInt();
//creating a LocalDate object and initializing it to null;
LocalDate inputDate=null;
try
{
/*we are using the 3 variables and converting it into a date object to compare it with today's date */
inputDate = LocalDate. of(yr, mo, da);
}
catch(Exception ex)
{
/*if the entered day, month & year are not converted to a date object because of invalid entry of any values, we are stopping the program.*/
System. out. println("You have made invalid entries, please try again !!");
System. exit(0);
}
/*if the date object is created after proper entries, we are using the built-in functions to compare it the today's date object*/
System. out. print("The date you entered is ");
if(inputDate. isBefore(today))
System. out. println("in the past.");
else
if(inputDate. isAfter(today))
System. out. println("in the future.");
else
if(inputDate. equals(today))
System. out. println("the current date.");
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 11:00
In the context of the box model, what is the difference between a margin and a padding? a. a padding lies outside a box border, while a margin lies inside it. b. a padding lies inside a box border, while a margin lies outside it. c. a padding can be adjusted independently, while a margin depends on the size of its box. d. a padding depends on the size of its box, while a margin can be adjusted independently.
Answers: 3
question
Computers and Technology, 23.06.2019 17:10
Ac++an of of pi. in , pi is by : pi = 4 – 4/3 + 4/5 – 4/7 + 4/9 - 4/11 + 4/13 - 4/15 + 4/17 . ., to pi (9 ). , if 5 to pi,be as : pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 = 4 – 1. + 0.8 - 0. + 0. = 3.. atoofbe to pi?
Answers: 2
question
Computers and Technology, 24.06.2019 16:00
Which of the following characters is acceptable to use in a filename? ? / – %
Answers: 1
question
Computers and Technology, 24.06.2019 18:30
After making a powerpoint presentation about a new line of clothing designs, henri notices that he used the word “gorgeous” on nearly every slide. what would be the  best  way to add more variety to his wording by using tools within powerpoint? using the thesaurus under the view tab, and then using the find dialog box to find and replace every instance of “gorgeous”using the spelling checker under the view tab, and then using the find dialog box to find every instance of “gorgeous” and change some of themusing the thesaurus under the review tab, and then using the find dialog box to find every instance of “gorgeous” and change some of themusing the spelling checker under the review tab, and then using the find dialog box to find and replace every instance of “gorgeous”
Answers: 2
You know the right answer?
Use the web to learn how to use the LocalDate Boolean methods isBefore(), isAfter(), and equals(). U...
Questions
question
Mathematics, 16.04.2020 03:22
question
Mathematics, 16.04.2020 03:23
question
Mathematics, 16.04.2020 03:23
question
Mathematics, 16.04.2020 03:23
Questions on the website: 13722367