Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello I am new to this forum and computer programming is general. I hope I poste

ID: 3537970 • Letter: H

Question

Hello I am new to this forum and computer programming is general.

I hope I posted to the right area after reading the rules.

I have a question about one area of the program I am working on.

I have posted copies of 2 of the 3 classes I am working on.

I am trying to update the variables (name, price) from the Testclass using the public void add(String name, double price) method.

I have tried a couple of different ways but none work.

Once I update them my average method should work.

Could anyone help?

Thank you


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

ping me on Skype : digiti.dgt

will help u

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote