Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program 1: Given a date, calculate the day of the week on which it falls. We will write a program that given any valid date

image text in transcribed
image text in transcribed
Program 1: Given a date, calculate the day of the week on which it falls. We will write a program that given any valid date since January 1, 1900, will then display the day of the week on which the date fell. (You may assume that the user will input a valid date) Your main method will prompt the user for a date in the format MM/DD/YYYY. It will read the date as a string, and then extract the day, month, and year from the String (using methods from class string) and convert them to integers (using methods from class Integer). Using the algorithm given below, you program should calculate the day of the week, and then print it out. IE: For the date 10/19/2015 your program should display a message in the format: Monday, October 19,2015 NOTE: date. Each execution of the program will process a single Note, all variables are integers and the divisions are integer divisions. y=year-a in month + 12 a-2 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. To determine the correct day name and month name, you will need to use a switch/case statement, which is explained in your text in chapter 5. A sample is given below A partially completed switch statement for the month name is given below String monthName; /declare this variable switch( month) case 1: month Nanne = "January". break; case 2: monthName "February" break; otherwise: 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. To determine the correct day name and month name, you will need to use a switch/case statement, which is explained in your text in chapter 5. A sample is given below A partially completed switch statement for the month name is given below String monthName; I/declare this variable switch( month) case l monthName- "January" break; case 2: monthName "February" break otherwise: monthName="Invalid Month!!!". A partially completed switch statement for the name of the day of the week is String day Name switch( dayNum) case 0: dayName- "Sunday" break; case 1: day Name "Monday" break otherwise dayName "Invalid DAY" What to submit: Your application program in the form of a java file

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

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 International Workshops Gdm Benchmarx Mcis Snsmw Diew Udm Tsukuba Japan April 2010 Revised Selected Papers Lncs 6193

Authors: Masatoshi Yoshikawa ,Xiaofeng Meng ,Takayuki Yumoto ,Qiang Ma ,Lifeng Sun ,Chiemi Watanabe

2010th Edition

3642145884, 978-3642145889

More Books

Students also viewed these Databases questions

Question

How do unearned revenues arise?

Answered: 1 week ago

Question

explain what is meant by redundancy

Answered: 1 week ago