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!
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.
|