Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We will write a program that given any valid date, will then display the day of the week on which the date fell. Your program

image text in transcribed
We will write a program that given any valid date, will then display the day of the week on which the date fell. Your program will prompt the user for a date in the form of a String in the format MM/DD/YYYY Your program must break the string into pieces for the month day and year. Next it must convert the day, month and year into integers and then validate the date (legal day, legal month and legal year). Also only consider dates since the year 1900 If the date is invalid, ie: 02/29/2015 your program should print out a message such as 02/29/2015 is NOT a valid date. If the date is valid use the following formula to calculate the day of the week as an integer betweern 0 & 6. For example for the date 10/19/2015, would print a message saying The date 10/19/2015 falls on a Monday Note, all variables are integers and the divisions are integer divisions (14 -month) 12 y year a m month + 12 a-2 d 12mmodulo 7 31 m daynum- dayy+4100 400t The month, day, and year variables used in the equation are the integer date values (10, 19 and 2015) from the previous example). The final value of daynum is 0- 6 with 0 representing Sunday and 6 representing Saturday You should write methods to calculate each part of the conversion, and to extract the different parts from the date Note: Use message and input dialog boxes for all input and output We will write a program that given any valid date, will then display the day of the week on which the date fell. Your program will prompt the user for a date in the form of a String in the format MM/DD/YYYY Your program must break the string into pieces for the month day and year. Next it must convert the day, month and year into integers and then validate the date (legal day, legal month and legal year). Also only consider dates since the year 1900 If the date is invalid, ie: 02/29/2015 your program should print out a message such as 02/29/2015 is NOT a valid date. If the date is valid use the following formula to calculate the day of the week as an integer betweern 0 & 6. For example for the date 10/19/2015, would print a message saying The date 10/19/2015 falls on a Monday Note, all variables are integers and the divisions are integer divisions (14 -month) 12 y year a m month + 12 a-2 d 12mmodulo 7 31 m daynum- dayy+4100 400t The month, day, and year variables used in the equation are the integer date values (10, 19 and 2015) from the previous example). The final value of daynum is 0- 6 with 0 representing Sunday and 6 representing Saturday You should write methods to calculate each part of the conversion, and to extract the different parts from the date Note: Use message and input dialog boxes for all input and output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

What is EVA, and how is it measured?

Answered: 1 week ago

Question

=+j Explain IHRMs role in global HR research.

Answered: 1 week ago

Question

=+j Describe an effective crisis management program.

Answered: 1 week ago