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 =0;
itemCount =0;
}
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 =0;
private int itemCount =0;
public void addItem(double price)
{
totalPrice = totalPrice + price ;
itemCount++;
}
public int getCount()
{
}
return itemCount;
public double getTotal()
{
return totalPrice;
 Rearrange the code below to provide two additional CashRegister methods: an

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!