Final answer:
To construct a cash register and process sales of items, you can rearrange the given lines of code in a specific order. By following the correct arrangement, you will be able to add items to the register, print the count and total for a sale, and then clear the register for the next sale.
Step-by-step explanation:
The given lines of code need to be rearranged in order to construct a cash register and process sales of items. Here is the correct arrangement:
- Create an instance of the CashRegister class: CashRegister regi = new CashRegister();
- Add the items to the register: regi.addItem(5.95); regi.addItem(1.95); regi.addItem(12.95);
- Print the count of items: System.out.println(regi.getCount());
- Print the total cost: System.out.println(regi.getTotal());
- Clear the register: regi.clear();
- Add new items to the register: regi.addItem(19.95); regi.addItem(2.95);
- Print the new count of items: System.out.println(regi.getCount());
- Print the new total cost: System.out.println(regi.getTotal());
By following this order, you will be able to construct a cash register, process two sales, and print the count and total cost for each sale.