I have 3 classes..but i need to print the outcome from the printArray.
Right now it is printing from the GetTax Compute class. I am so confused.
Class 1...
public class PosCalProgram {
public static void main(String[] args) {
double x = 0;
item[] items = new item[3];
items[0]=new item("521412", "Shoes", 200);
items[1]=new item("823153", "Shirt", 100);
items[2]=new item("638212", "Pants", 400);
printArray(items);
GetTax c = new GetTax(0.07,0.08);
double z = c.compute(items);
}
public static void printArray(item[] y){
int size = y.length;
for (int i=0; i < size; i++){
item x =y[i];
}}
}
Class 2....
public class GetTax {
private double Gst;
private double Pst;
private double GstTaxes;
public GetTax(double GetGst, double GetPst){
Gst = GetGst;
Pst = GetPst;
}
public double compute(item[] items){
double total = 0;
//compute the price
PosCalProgram x = new PosCalProgram();
int size = items.length;
for (int i=0; i < size; i++){
item z=items[i];
double PstTax = Pst * z.price;
double GstTax = Gst * z.price;
double aftertax = GstTax + PstTax + z.price;
System.out.println(z.barCode + " " + z.name + " " + z.price + " " + GstTax + " " + PstTax + " " + aftertax);
total = total + aftertax;
}
System.out.println("Total Amount is : " + total);
return total;
}
}
Class 3....
public class item {
public String barCode = null;
public String name = null;
public double price = 0;
public item(){
}
public item(String s1, String s2, double d1){
barCode = s1;
name = s2;
price = d1;
}
}
any help would be appreciated