Answer to Question #2559 in Java | JSP | JSF for zaara

Question #2559
Design and implement a class called DateWriter that has three instance variables: a string for month, an integer for day, and an integer for year. The class should has a constructor to accept and initialize the values of the instance variables, and a getter and a setter method for each instance variable. Include the following methods: 1) A method called monthInteger that has no parameters and returns an integer value represents the month. 2) A method called monthString that has a parameter monthNumber of type integer and returns a string represents the month. 3) A method called setDate that has three integer parameters: newMonth, newDay, and newYear. The method should set the three instance variables, even though the month instance variable is of type string, you have to convert the month integer value to a string with a call to method monthString. 4) A method called makeItNewYear that has no parameters and sets the month instance variable to “January” and the day instance variable to 1. It doesn’t change the value of the year instance variable. 5) A method called yellIfNewYear that has no parameters and outputs the string “Hurrah!” if the month instance variable has the value “January” and the day instance variable has the value 1. Otherwise, it outputs the string “Not new year’s day.” 6) A method called getNextYear that has no parameters and returns an integer value represents the next year. 7) A method called fractionDone that has a parameter targetDay of type integer (for a day of a month) and returns a value of type double. The value returned is the value of the day instance variable divided by the integer parameter targetDay. (so it returns the fraction of the time passed so far this month where the goal is reaching the targetDay). Note: Do floating-point division not integer division, and Check the value of the targetDay if it’s not a valid day of a month, then print an error message to the standard output and return zero to the caller. 8) A method called advanceYear that has one parameter of type integer. The method advanceYear increases the value of the year instance variable by the amount of this one parameter. Finally, create a driver (main or client) class called DateDemo, whose main method instantiates several (at least 3 DateWriter objects) and uses all methods you created. Prompt the user to enter the data.
Expert's answer
Your question requires a lot of work and cannot be done for free. Submit it as an assignment to our control panel and we'll assist you.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog