Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Finding dates in Java What Your Program Will Do Write a program from scratch that accomplishes the following: 1. Create a new Java class file

image text in transcribed

Finding dates in Java

What Your Program Will Do Write a program from scratch that accomplishes the following: 1. Create a new Java class file named Dates.java that implements a Dates class. 2. Create an instance/object of the SimpleDate class that is the default value and print this value on the first line of output by itself. There isn't anything specific in the API about how to print a SimpleDate object; you should try different (obvious) ways of outputting an object's value. 3. Create another instance/object of the SimpleDate class that specifically represents your birthday. Print this value on the next line by itself. 4. Create an instance/object of the Random class. 5. Using your Random object, generate 3 numbers that will be used as a month, day and year. Ensure that the three values you create are valid values as defined below: The value you generate for the month should be between 1 and 12 inclusive. The value for the day should be between 1 and 28 inclusive. We don't have techniques yet to create values that are appropriate to each month (i.e., 28, 29, 30, or 31 depending on month and leap year status), so the range 1-28 will be sufficient. The value you generate for the year should be between 1800 and 2200 inclusive. Using a basic output statement (i.e., System.out.println() , System.out.print() or System.out.printf() , print these values on the next line with each value separated by a single space. 6. Using the appropriate method or methods (refer to the API), set the SimpleDate object that was previously created in step 3 to the values generated in step 5. Make sure to use the same object you previously used and methods from the SimpleDate class to change the previous values in the object. Print this object on the next line by itself. 7. Use the nextDay() method from the SimpleDate class to modify the object from step 6 and then print the new date on the next line by itself. 8. Now update the SimpleDate object from steps 6 and 7 three more days (for a total of four days after the original random date) and then print the updated date on the next line by itself. 9. Finally, output the date from the previous step in the format dd-mm-yyyy (days and months do not have to be two digits; see example runs). Print this value on a line by itself. Hint: a SimpleDate object can tell you about its individual values if you ask it nicely

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 Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

=+j Describe how EU directives impact IHRM.

Answered: 1 week ago

Question

What is focal length? Explain with a diagram and give an example.

Answered: 1 week ago

Question

What is physics and how does it apply in daily life?

Answered: 1 week ago