Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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!

Java, Programming

  • Category:- Java
  • Reference No.:- M91611888
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Java

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As