160k views
2 votes
Write a class called Cashier that directs a cashier how to cash goods and give change to customers. The typical cashier operations are as follows: (a) Cashier clears the cash register machine. (b) Cashier enters the name and the price of each item in the cash registering machine. (c) The customer tenders an amount of money to pay for the goods (We assume the amount covers the total). (d) The cash machine computes: a. The number of items purchased b. The total amount of purchase c. The average price of each item d. The number of coin denominations that the customer should receive. That is, the number of silver dollars, quarters, dimes, nickels, and cents the customer should receive in turn java

User Sestocker
by
6.5k points

1 Answer

6 votes

Class Cashier that directs a cashier how to cash goods and give change to customers based on cashier operations is given below.

Step-by-step explanation:

Use the following class, TestCashier, as the basis for the test class.

class TestCashier

{

public static void main(String[] arg)

{

Cashier c = new Cashier();

String name = GetData.getWord(“Enter name of item”);

double price = GetData.getDouble(“Enter price of item”);

c.add(name, price);

name = GetData.getWord(“Enter name of item”);

price = GetData.getDouble(“Enter price of item”);

c.add(name, price);

// Add a two more entries of your own

// Now average the price of the items

c.average();

// Make payment

double amount = GetData.getDouble(“Enter amount of money for payment”);

c.tendered(amount); // For example twenty dollars were tendered

c.makeChange();

generateReceipt(c);

}

static void generateReceipt(Cahier c)

{

// Write the necessary code that will generate a customer’s receipt.

// The output must be displayed in a scrollable pane

}

}

Description of the output:

The output should be displayed in a scrollable pane, and have the following features:

• The first line displays the name of the establishment.

• Second line reads something like this: Welcome – thanks for stopping, followed by the current date

• The list of items displayed, one item per line – That is, the name of the product and price,

• The sum of all the items

• The number of items purchased

• The average price for each item

• The amount of money tendered

• The amount of change in $ and cents

• The change given in coin denominations

Here is an example of the form of how the output should be ( except that this output must be displayed in a scrollable pane).

Bread............ 2.99

Chicken..........6.79

Egg..................3.07

______________

Total ……….$12.85

The number of items purchased is 3 items

The average price per item is $4.28

Amount tendered is $20.00

The change is $7.15

The change includes

7 dollars

0 quarters

1 dimes

1 nickels

0 cents

User Wizz
by
7.3k points