This is a fairly basic program. When I try to print the summaryOutput
method and billOutput
method, I get errors saying the parameters cannot be resolved as a variable.
public class PizzaDriver{
public static void main(String[] args) {
PizzaOrder order = new PizzaOrder();
PizzaOutput output = new PizzaOutput();
PizzaInput input = new PizzaInput();
System.out.println(output.menuOutput());
input.readInput(order);
System.out.println(summaryOutput1 = output.summaryOutput (numCheese, numPepperoni, numSausage, numVegetarian));
System.out.println(output.billOutput(String billOutput));
}
}
public class PizzaOutput {
public String menuOutput()
{
String menuOutput1 = "Item \t Price \nCheese \t $2.40 \n Sausage \t $3.00 \nPepperoni \t $3.00 \nVegertarian \t $3.00";
return menuOutput1;
}
public void summaryOutput(int numCheese,int numPepperoni,int numSausage,int numVegetarian)
{
System.out.println("Cheese: " + numCheese);
System.out.println("Pepperoni: " + numPepperoni);
System.out.println("Sausage: " + numSausage);
System.out.println("Vegetarian: " + numVegetarian);
}
public void billOutput(double subTotal, double tax, double carryOut, double totalBill)
{
System.out.println("Subtotal : " +subTotal);
System.out.println("Tax : " + tax);
System.out.println("carryOut : " +carryOut);
System.out.println("Total Bill: " + totalBill);
}
import java.util.Scanner;
public class PizzaInput { Scanner keyboard = new Scanner(System.in);
public int numCheese, numPepperoni, numSausage, numVegetarian;
public void readInput(PizzaOrder order)
{
System.out.print("How many Cheese Pizzas would you like?");
int numCheese = keyboard.nextInt();
order.setCheese(numCheese);
System.out.print("How many Pepperoni pizzas would you like?");
int numPepeperoni = keyboard.nextInt();
order.setPepperoni(numPepperoni);
System.out.print("How many Sausage pizzas would you like?");
int numSausage = keyboard.nextInt();
order.setSausage(numSausage);
System.out.print("How many Vegetarian pizzas would you like?");
int numVegetarian = keyboard.nextInt();
order.setVegetarian(numVegetarian);
}
}
public class PizzaOrder { private final double CHEESE_PRICE = 2.40;
private final double PEPPERONI_PRICE = 3.00;
private final double SAUSAGE_PRICE = 3.00;
private final double VEGETARIAN_PRICE = 3.50;
private final double SALES_TAX = .025;
private final double CARRY_OUT = .10;
public int numCheese, numPepperoni, numSausage, numVegetarian;
public int getCheese()
{
return numCheese;
}
public void setCheese(int numCheese)
{
this.numCheese=numCheese;
}
public int getPepperoni()
{
return numPepperoni;
}
public void setPepperoni(int numPepperoni)
{
this.numPepperoni=numPepperoni;
}
public int getSausage()
{
return numSausage;
}
public void setSausage(int numSausage)
{
this.numSausage= numSausage;
}
public int getVegetarian()
{
return numVegetarian;
}
public void setVegetarian(int numVegetarian)
{
this.numVegetarian = numVegetarian;
}
public double calculateSubTotal()
{
double cheeseTotal= numCheese * CHEESE_PRICE;
double pepperoniTotal = numPepperoni * PEPPERONI_PRICE;
double sausageTotal = numSausage * SAUSAGE_PRICE;
double vegetarianTotal = numVegetarian * VEGETARIAN_PRICE;
double subTotal = cheeseTotal + pepperoniTotal + sausageTotal + vegetarianTotal;
double tax = (subTotal) * SALES_TAX;
double totalBill = (tax + subTotal) * CARRY_OUT;
return totalBill;
}
}