Question: Rearrange the code below to provide two additional CashRegister methods: an enterpayment method that reduces the total price by the given payment, and a givechange
Rearrange the code below to provide two additional CashRegister methods: an enterpayment method that reduces the total price by the given payment, and a givechange method that returns the change due and resets the total price and item count.
Not all lines are useful.
How to use this tool
Unused
totalPrice ;
itemCount ;
amount amount totalPrice;
totalPrice totalPrice amount;
public void giveChange
public double giveChange
return totalPrice;
return change;
double change totalPrice;
Anuhle rhanne tntalprice.
CashRegister.java
Load default template...
public class CashRegister
private double totalPrice ;
private int itemCount ;
public void addItemdouble price
totalPrice totalPrice price ;
itemCount;
public int getCount
return itemCount;
public double getTotal
return totalPrice;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
