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 a class safestack that implements a stack of strings

Create a class SafeStack that implements a stack of strings

  Replace the submit button

Replace the submit button (type="submit")with a regular button (type="button").  Once the buttonis clicked, display the user inputs in an HTML table below the form, if validations are successful

  Implement a program to reverse the digits

Write a method, reverseDigit, that takes an integer as a parameter and returns the number with its digits reversed. For example, the value of reverseDigit(12345) is 54321.

  When are stubs & skeletons created for my ejb components

When are stubs & skeletons created for my EJB components? is it at development time, deployment time or run time?

  Prepare a second class to test the receipt class

Prepare a second class to test the receipt class - Make this program using java programming. Make this application in simple way.

  Create a gui application with jframe

Create a GUI application with JFrame that contains five labels describing reasons that a customer might not buy a specific product (e.g. too expensive).

  You will need a bottomuptwothreefourtree class with a

you will need a bottomuptwothreefourtree class with a bottomuptwothreetreefourtree constructor which takes no

  Your task is to design and implement a sorting

your task is to design and implement a sorting algorithmalgorithm that can sort nonnegative integers that fall within

  Write a server for multiple clients

Write a server for multiple clients. The client sends loan information (annual interest rate, number of years, and loan amount) to the server. The server computes monthly payment and total payment and sends them back to the client.

  Follow the projects suggestion

Be sure that you follow the projects suggestion and create a separate class for the word analysis. An instance of this class and its methods should then be called by your GUI interface.

  Create an array that stores in integers from the keyboard

create an array that stores in integers from the keyboard and then I can scan that array to check numbers in order, if the number I check is greater than the previous then I will set the next number in the array to the higher value.

  Create a project using the classes in the doc sharing area

create a project using the classes in the Doc Sharing area labeled A Simple LinkedList class. Compile it, run it, and review the code that is given carefully. This code tests the LinkedList class provided in the lecture.

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