Write a class called cashier that directs a cashier


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) Enter the name of and price of each item in the cash registering machine.
(b) The machine totals the cost of the items as they are entered.
(c) The customer tenders an amount to pay for the goods (We assume the amount covers the total).
(d) The cash machine computes:
i. The number of items purchased
ii. The total amount of purchase
iii. The average price of each item
iv. 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. In addition.
Here is a typical 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 few 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); // 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 - the name 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 

See below, 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

NB: Use the class GetData to enter the data. This means that your program MUST consist of three classes: GetData.java, Cashier.java, and TestCashier.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Write a class called cashier that directs a cashier
Reference No:- TGS0134927

Expected delivery within 24 Hours