write the code and output result1 real cash


Write the code and output result.

1. Real cash register can handle both bills and coins. Design a single class that expresses the commonality of these concepts. Redesign the CashRegister class and provide a method for entering payments that are described by your class. Your primary challenge is to come up with a good name for this class.

2. Enhance the BankAccount class by adding preconditions for the constructor and the deposit method that require the amount parameter to be at least Zero, and a precondition for the withdraw method that requires amount to be a value between 0 and the current balance. Use assertions to test the preconditions.

3. Consider the following algorithm for computing Xn  for an integer n. If n<0, Xn is 1/x-n . If n is positive and even, then xn= (xn/2)2. If n is positive and odd, then Xn=xn-1.x. Implement a static method double intPower (double x, int  n) that uses this algorithm. Add it to a class called numeric.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: write the code and output result1 real cash
Reference No:- TGS0445867

Now Priced at $30 (50% Discount)

Recommended (95%)

Rated (4.7/5)