subject

Java Programming Create a USMoney class with two private integer instance variables named dollars and cents. Add a constructor with two parameters for initializing a USMoney object. The constructor should check that the cents value is between 0 and 99 and, if not, transfer some of the cents to the dollars variable to make it between 0 and 99.
Add a plus() method to the class that takes a USMoney object as its parameter. It creates and returns a new USMoney object representing the sum of the object whose plus() method is being invoked and the parameter. Hint: Your USMoney object may require both a getDollars() method and a getCents() method.
The plus() method does not modify the values of the two existing objects. It should also ensure that the value of the cents instance variable of the new object is between 0 and 99.
For example, if x is a USMoney object with 5 dollars and 80 cents, and if y is a USMoney object with 1 dollar and 90 cents, then x. plus(y) will return a new USMoney object with 7 dollars and 70 cents.
Of course, you will need to create a USMoneyDemo class that tests the USMoney class. Your USMoneyDemo should prompt the user twice. The first to enter an integer representing dollars and the second to enter an integer representing cents. Use these values to create the first object named x. Do it again for the object named y. Do not worry about putting these prompts in a loop for now.
Be sure to add some documentation and put any partner(s) names in the main application's doc box.
For Part 1, submit two files on Blackboard: USMoney. java and USMoneyDemo. java
Part 2 – 25 points
Create a Date class with three private integer instance variables named day, month, year. It has a constructor with three parameters for initializing the instance variables, and it has a method named daysSinceJan1(). Note: It could have other methods.
Just as its identifier suggests, the daysSinceJan1() method computes and returns the number of days since January 1 of the same year, including January 1 and the day in the Date object itself.
Create a DateDemo class that tests the Date class. First prompt the user to enter an integer representing the day, a second prompt to enter an integer representing the month and a third to enter an integer representing the year. (Do not worry about doing any validation of the values entered.) Then, instantiate your Date object with these values. After that, call the method DaysSinceJan1() to display the answer.
An example would be that the user enters values of day = 1, month = 3, and year = 2019, then the call day. daysSinceJan1() should return 60 since there are 60 days between the dates of January 1, 2019, and March 1, 2019. In leap years, it should return 61.
Note that, in a leap year like 2020 will be, there will be one more day counted between January 1 and any date following February 28. What are the rules for leap years? If the year is evenly divisible by four, then it is a leap year...but not always! If it is a century year such as 1900 or 2000, it is only a leap year if evenly divisible by 400. Therefore, the century year 2000 WAS a leap year but 1900 was NOT a leap year! Neither were 1700 or 1800 and neither will be 2100...but 1600 was!
You may NOT use an Array or ArrayList (or any other type of array) and you may not use any of the Java API date classes and/or methods.
Document like you did for Part 1.
For Part 2, submit two files on Blackboard: Date. java and DateDemo. java

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 14:00
The table in columns a-c contains a list of paint color choices for a bathroom and a laundry room. what is a possible sequence of parameters used to organize the data as shown in columns e-g?
Answers: 3
question
Computers and Technology, 21.06.2019 20:50
Write a method in the heapintpriorityqueue class called merge that accepts another heapintpriorityqueue as a parameter and adds all elements from the other queue into the current queue, maintaining proper heap order such that the elements will still come out in ascending order when they are removed. your code should not modify the queue passed in as a parameter. (recall that objects of the same class can access each other's private fields.)
Answers: 2
question
Computers and Technology, 22.06.2019 01:00
)a grad student comes up with the following algorithm to sort an array a[1..n] that works by first sorting the first 2/3rds of the array, then sorting the last 2/3rds of the (resulting) array, and finally sorting the first 2/3rds of the new array. 1: function g-sort(a, n) . takes as input an array of n numbers, a[1..n] 2: g-sort-recurse(a, 1, n) 3: end function 4: function g-sort-recurse(a, `, u) 5: if u ⒠` ≤ 0 then 6: return . 1 or fewer elements already sorted 7: else if u ⒠` = 1 then . 2 elements 8: if a[u] < a[`] then . swap values 9: temp ↠a[u] 10: a[u] ↠a[`] 11: a[`] ↠temp 12: end if 13: else . 3 or more elements 14: size ↠u ⒠` + 1 15: twothirds ↠d(2 ◠size)/3e 16: g-sort-recurse(a, `, ` + twothirds ⒠1) 17: g-sort-recurse(a, u ⒠twothirds + 1, u) 18: g-sort-recurse(a, `, ` + twothirds ⒠1) 19: end if 20: end function first (5 pts), prove that the algorithm correctly sorts the numbers in the array (in increasing order). after showing that it correctly sorts 1 and 2 element intervals, you may make the (incorrect) assumption that the number of elements being passed to g-sort-recurse is always a multiple of 3 to simplify the notation (and drop the floors/ceilings).
Answers: 3
question
Computers and Technology, 22.06.2019 11:00
What are two of the most common reasons that peolpe who need mental health care do not access it?
Answers: 1
You know the right answer?
Java Programming Create a USMoney class with two private integer instance variables named dollars...
Questions
question
History, 12.05.2021 18:50
question
Mathematics, 12.05.2021 18:50
question
Mathematics, 12.05.2021 18:50
question
Mathematics, 12.05.2021 18:50