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 MMDD/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 1019/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 m month + 12 x 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: monthName "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 1: monthName "January" break; case 2 monthName "February"; break: otherwise month Name- "Invalid Month!! A partially completed switch statement for the name of the day of the week is: String dayName switch( dayNum) case 0: dayName "Sunday" break; case 1: dayNameMonday" break; otherwise day-Name ="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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

a. P(T13 ?) = .10 b. P(|T28| 2.05) = ?

Answered: 1 week ago

Question

1. What are the pros and cons of diversity for an organisation?

Answered: 1 week ago

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago