Question: PARTICIPATION 8 . 6 . 2 : Rearrange the code to provide two additional CashRegister methods. Full screen ACTIVITY Rearrange the code below to provide

PARTICIPATION
8.6.2: Rearrange the code to provide two additional CashRegister methods.
Full screen
ACTIVITY
Rearrange the code below to provide two additional CashRegister methods: an enterpayment method that reduces the to 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 v
Unused
public double givechange()
{
public void giveChange()
{
totalPrice =0;
itemCount =0;
return change;
return -totalPrice;
}
}
double change =- totalPrice;
double change = totalPrice;
amount = amount - totalPrice;
CashRegister.java
Load default template.
private double totalPrice =0;
private int itemCount =0;
public void addItem(double price)
{
totalPrice = totalPrice + price ;
itemCount++;
}
public int getCount()
q
return itemCount;
}
public double getTotal()
{
return totalPrice;
}
 PARTICIPATION 8.6.2: Rearrange the code to provide two additional CashRegister methods.

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!