Calculate the new date by adding a fixed number of days

Assignment Help JAVA Programming
Reference no: EM13941015

Textbook has given a .java file named "date.java", but it is not perfect;
What I have done is the "ExtendedDate.java", which improved the "data.java" that the program will firstly check if the date input from users is valid then store it with the setDate method. Additionally, the "ExtendedDate.java" has the function including of:
1. Set the month.
2. Set the day.
3. Set the year.
4. Return the month.
5. Return the day.
6. Return the year.
7. Test whether the year is a leap year.
8. Return the number of days in the month.
9. Return the numbers of the days passed in the year.
10. Return the number of the days remaining in the year.
11. Calculate the new date by adding a fixed number of days to the date.
"TestExtendedDate.java" will call the methods of "ExtendedDate.java", than print out all the results.
I attached the three java files already;
1. Date.java
2. ExtendedDate.java
3. TestExtendedDate.java

Now what I need you help is to finish an "exception" part of my program. It is to add creating and handling of Exceptions when an attempt is made to create an invalid date. The Exception object must return information to the user about the nature of the problem that occurred.
Please do not change any method's name and the return type, thanks.
Here is a sample run result of my program:
1.
Please enter Month, Day and Year with spaces(MM/M DD/D YYYY):

15 15 1950
Invalid date and don't see the following jugement which will be also invalid.
Given Date is:1-1-1900
1950 is leap year:false
Current Date is 1-1-1900 and Days in current Month is 31
Current Date is 1-1-1900 and Days Passed is 1
Current Date is 1-1-1900 and Days Remained is 364
Enter num of days to be added:

2.
Please enter Month, Day and Year with spaces(MM/M DD/D YYYY):

12 11 1999
Given Date is:12-11-1999
1999 is leap year:false
Current Date is 12-11-1999 and Days in current Month is 31
Current Date is 12-11-1999 and Days Passed is 345
Current Date is 12-11-1999 and Days Remained is 20
Enter num of days to be added:
100
The new date is 3-20-2000

3.
Please enter Month, Day and Year with spaces(MM/M DD/D YYYY):

12 12 2998
Given Date is:12-12-2998
2998 is leap year:false
Current Date is 12-12-2998 and Days in current Month is 31
Current Date is 12-12-2998 and Days Passed is 346
Current Date is 12-12-2998 and Days Remained is 19
Enter num of days to be added:
500
New Date is out of range!

Reference no: EM13941015

Questions Cloud

Develop a local or national campaign to promote the city : You are a public relations practitioner working for Sheffield City Council. Develop a local or national campaign to promote the city.
Advantages and disadvantages on taxing worldwide income : Please read the article in the link below and discuss the advantages and disadvantages on taxing worldwide income of corporations immediately at a reduced rate versus waiting until the profits are returned to the U. S
Product life cycle theory and the transaction cost theory : Discuss the key differences among the comparative advantage theory the product life cycle theory and the transaction cost theory.
Entering into a foreign market : Why is it important to do market research and adjust the marketing mix when entering into a foreign market? Explain the theory and then give practical examples of how some companies have already adjusted their marketing mix in foreign markets.
Calculate the new date by adding a fixed number of days : What I have done is the "ExtendedDate.java", which improved the "data.java" that the program will firstly check if the date input from users is valid then store it with the setDate method.
Process technology and e-business literature : Your report should include references to appropriate process technology and e-business literature (textbooks, journals and websites). Care should be taken when consulting websites as they are not all equally authoritative
Create the general ledger accounts : Create the general ledger accounts, and enter the initial balances at the start of the month of January. This requirement is already completed on the worksheets. Prepare journal entries for January's transactions
Working to develop a coherent link of argument : While your report presented information on this topic, your research essay must explore this issue in greater detail, working to develop a coherent link of argument or discussion in a compelling essay founded upon a clear thesis.
Why is overloading useful : Overloading is a way of using the same method name for multiple methods as long as the number / types of arguments are different. Why is overloading useful? Give an example of how this could be used.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd