Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java please. Thanks Extra Credit Exercise 24: USMoney Create a USMoney class with two integer instance variables dollars and cents. Adda constructor with two

In java please. Thanks

image text in transcribed

Extra Credit Exercise 24: USMoney Create a USMoney class with two integer instance variables dollars and cents. Adda 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, transter some of the cents to the dollars variable to make it between 0 and 99. Add a plus method to the dass 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. It does not modity 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 O 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 7O cents. Also, create a USMoneyDemo class that tests the USMoney class. Exercise 25: Date Create a Date class with three integer instance variables named day, month, year. It has a constructor with three parameters for initializing the instance variables, and it has one method named daysSinceJan1). It computes and returns the number of days since January 1 of the same year, including January 1 and the day in the Date object. For example, if day is a Date object with day 1, month 3, and year 2000, then the call date.daysSinceJan1() should return 61 since there are 61 days between the dates of January 1, 2000, and March 1, 2000 including January 1 and March 1. Include a DateDemo class that tests the Date class. Don't forget leap years. . Exercise 26: Dolt What is the difference, if anything, between the following two implementations of the method dolt()? void doIt (int x) if (x0) System.out-println("Pos" else System.out-printin ("Neg" void doIt (int x) ( if(x > 0) { System.out printin"Pos" return; System.out printin ("Neg")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

Acceptance of the key role of people in this process of adaptation.

Answered: 1 week ago

Question

preference for well defined job functions;

Answered: 1 week ago