Your friend Chuck owns several pizza stands distributed thro
Your friend Chuck owns several pizza stands distributed throughout the town. You are the java expert who will help Chuck keep track of the number of pizzas sold by the stand as well as the total number of pizzas sold in all the stands. For this, define a class named PizzaStand that has an instance variable for the Pizza Stand’s ID number and an instance variable for how many pizzas sold in that stand that day. Add a static variable that tracks the total number of pizzas sold by all the stands. Add another static variable that specifies the cost per pizza.
Exercise 2: Your friend Chuck owns several pizza stands distributed throughout the town. You are the java expert who will help Chuck keep track of the number of pizzas sold by the stand as well as the total number of pizzas sold in all the stands. For this, define a class named PizzaStand that has an instance variable for the Pizza Stand\'s ID number and an instance variable for how many pizzas sold in that stand that day. Add a static variable that tracks the total number of pizzas sold by all the stands. Add another static variable that specifies the cost per pizza. Add the following methods: A constructor that sets the ID number to some value and the number of pizzas sold by that stand to 0 A method named justSold that increments the number of pizzas sold by that stand by 1 Another method to return the number of pizzas sold by that stand. A static method to set the cost per pizza. A static method that returns the total number of pizzas sold by all stands A static method to return the total sales. Test the class for at least three different input sets (each with at least five pizza stands) that each sell a number of pizzas during the day. A sample screen dialog is given below. The cost of the pizza is set to $5.00. Pizza Sales 1 2 (means that Pizza Stand 1 sold 2 pizzas) 1 1 1 Total pizzas sold 6 Total sales: $30.00 Process completed What to submit: Pizza.java, PizzaDemo.java and the outputs generated by your code for the input sets in a text file.Solution
public class PizzaStand
{
private int ID;
private int num;
private static int total=0;
private static double cost;
public PizzaStand(int n)
{
ID = n;
num = 0;
}
public static void setCost(double c)
{
cost = c;
}
public void justSold()
{
num++;
total++;
}
public int getNumSold()
{
return num;
}
public static int getTotal()
{
return total;
}
public static double getSales()
{
return (total*cost);
}
public String toString()
{
return (ID + \"\\t\" + num + \"\ \");
}
}
//PizzaDemo.java
public class PizzaDemo
{
public static void main(String[] args)
{
PizzaStand.setCost(5.00);
PizzaStand One = new PizzaStand(1);
PizzaStand Two = new PizzaStand(2);
PizzaStand Three = new PizzaStand(3);
PizzaStand Four = new PizzaStand(4);
PizzaStand Five = new PizzaStand(5);
One.justSold();
Two.justSold();
Three.justSold();
Four.justSold();
Five.justSold();
One.justSold();
System.out.println(\"Pizza Sales: \");
System.out.println(One +\"\ \" + Two + \"\ \" + Three +\"\ \" + Four+\"\ \" + Five);
System.out.println(\"Total pizzas sold: \" + PizzaStand.getTotal());
System.out.println(\"Total sales: \" + PizzaStand.getSales());
}
}

