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

  Create an interface that includes a group box

Create an interface that includes a group box that contains 3 check box and 3 text box, the three text boxes should be invisible when the application starts

  Produce a fully functional gui program

Produce a fully functional GUI program in accordance with the specifications mentioned below. The program will be used to determine and display the final mark of students

  Java program which demonstrates cellular automata

Using the internet, locate a Java program (or Java applet) which demonstrates "Cellular Automata", in particular "the Game of Life".

  Create a class named blooddata

Create a class named BloodData that includes fields that hold a blood type (the four blood types are O, A, B, and AB) and an Rh factor

  Why does the program end abnormally

Using the Person and PersonRunner classes below, execute the main method in PersonRunner. Why does the program end abnormally?

  Write a program displaying a text file

Write a program displaying a text file that is in a text area - The user enters a file name in a text field and clicks the view button; the file is then displayed in the text area. Do not use BufferedInputStream.

  Creates a professorraing class consisting of professor ID

Write a program that creates a professorRaing class consisting of professor ID and three ratings. The three ratings are used to evaluate easiness, helpfullness, and clarity. In a separate implementation class, allow the user to enter the values.

  Pacman style game with clara

The major assignment involves producing a Pacman style game with Clara using the Greenfoot files that are given to you.

  Client server chat system

Threading and GUI design using Java's network library, threading system, and swing user interlace libraries to implement a basic chat client and saver system. Thc system will allow multiple. remote users to send and receive messages across the net..

  Implement the finite field gf

Write a program called "GF2.java" to implement the finite field GF(p n )where p is a prime number andn is a positive integer.You also need to write four methodsto realize.

  Mutant bacterium-synthesize the amino acid tyrosine

Consider a mutant bacterium you have isolated which is unable to synthesize the amino acid tyrosine. You grow it in the presence of a chemical mutagen and isolate a single revertant, which is now able to grow in the absence of tyrosine

  Prepare a class called geometrycalculator

Calculates the area of a circle of a given radius and write a class called GeometryCalculator that includes the subsequent methods

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