package Cashier1; import java.lang.Math; public class Cashier { public static fi
ID: 3538005 • Letter: P
Question
package Cashier1;
import java.lang.Math;
public class Cashier
{
public static final double SILVER_VALUE = 0.5;
public static final double QUARTER_VALUE = 0.25;
public static final double DIME_VALUE = 0.1;
public static final double NICKEL_VALUE = 0.05;
public static final double PENNY_VALUE = 0.01;
private String name;
private double price;
private String name1;
private double price1;
private String name2;
private double price2;
private String name3;
private double price3;
private double average;
private double purchase;
private double payment;
public void add(String name, double price)
{
this.name = name;
this.price = price;
this.name1 = name;
this.price1 = price;
this.name2 = name;
this.price2 = price;
this.name3 = name;
this.price3 = price;
}
public void average()
{
average = (price + price1 + price2 + price3)/4;
}
public double getAverage()
{
return average;
}
public Cashier()
{
purchase = 0;
payment = 0;
}
public void enterPayment(int dollars, int silver, int quarters, int dimes, int nickles, int pennies)
{
payment = dollars + silver * SILVER_VALUE + quarters * QUARTER_VALUE
+ dimes * DIME_VALUE + nickles * NICKEL_VALUE + pennies * PENNY_VALUE;
}
public double giveChange()
{
double change = payment - purchase;
purchase = 0;
payment = 0;
return change;
}
public Cashier(String name, double price)
{
this.name = name;
this.price = price;
}
public void calculate()
{
}
public void givechange()
{
}
}
package Cashier1;
import java.util.Date;
import java.text.DateFormat;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
class TestCashier
{
public static void main(String[] arg)
{
System.out.println("Joseph's Store to by stuff @");
System.out.println("Thanks for stopping");
Date d = new Date();
DateFormat df = DateFormat.getDateInstance(DateFormat.FULL);
System.out.println(df.format(d));
//String[] names;
//names = new String[4];
Cashier c = new Cashier();
String name = GetData.getWord("Enter name of item");
double price = GetData.getDouble("Enter price of item");
c.add(name, price);
String name1 = GetData.getWord("Enter name of item");
double price1 = GetData.getDouble("Enter price of item");
c.add(name1, price1);
// Add a two more entries of your own
String name2 = GetData.getWord("Enter name of item");
double price2 = GetData.getDouble("Enter price of item");
c.add(name2, price2);
String name3 = GetData.getWord("Enter name of item");
double price3 = GetData.getDouble("Enter price of item");
c.add(name3, price3);
// Now average the price of the items
c.average();
System.out.println(c.getAverage());
// 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(Cashier c)
{
// Write the necessary code that will generate a customer%u2019s receipt.
// The output must be displayed in a scrollable pane
}
}
Explanation / Answer
Its too hard to get the code
can you please repost the question with
appropriate spaces and new lines and tabs
because a programmer really needs this to interpret.
Please do rate me
i am here to help you always
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.