Question
Write a Java program that asks users to input a year in integer number and the day number of a week for the Valentines Day
Write a Java program that asks users to input a year in integer number and the day number of a week for the Valentines Day in that year; and the program calculates and displays the day NAME of a week for the next Valentines Day.
a) Your class should be named NextValentineDay, and your source code file should be named NextValentineDay.java.
b) Use int type for user inputs of year and day number of a week for the Valentines Day. Sunday is Day 0, Monday is Day 1, and Saturday is Day 6.
c) Determine if the provide year is a leap year or not. A leap year has 366 days till the next Valentines Day, while a non-leap year has 365 days till the next Valentines Day.
d) Use remainder (%) operation to decide the day number of a week for the next Valentines Day.
e) Use switch statements to display the result. The result must show the day NAME of a week for the next Valentines Day, like Sunday, Monday, Tuesday, etc. (not a day number anymore).
f) Add a comment at the very end of your program: If we modify this program to find out the day of the week for the next Christmas day, what key changes we need to make in this program?
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