Question
What is wrong with my JAVA Code? When I run the Compiler in Eclipse, it does not run. Please propose a fix. I was trying
What is wrong with my JAVA Code? When I run the Compiler in Eclipse, it does not run. Please propose a fix. I was trying to answer the following question.
Reimplement the CashRegister class so that it keeps track of the price of each added item in an ArrayList
--------------------
/** * Re-implement the CashRegister class so that it keeps track of the total price as an integer: the total cents of the price. **/
import java.util.ArrayList;
public class CashRegister02 { private ArrayList
// Gets the price of all items in the current sale.
public double getTotal() { double total = 0; for (double el : prices) { total += el; } return total / 100; } // Gets the number of items in the current sale.
public int getCount() { return prices.size(); }
// Clears the item count and the total using clear() method for ArrayList.
public void clear() { prices.clear(); }
// Displays all prices in the array.
public void displayAll() { for (int el : prices) { System.out.print(el + " "); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started