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

Problem1: Define a class called Pizza that has member variables to track the typ

ID: 3565191 • Letter: P

Question

Problem1: Define a class called Pizza that has member variables to track the type of pizza (either deep dish, hand tossed, or pan) along with the size (either small, medium, or large) and the number of pepperoni and cheese toppings. You can use constants to represent the type and size. Your class will have four member variables: size, type, pepperoniToppings, cheeseToppings. Include mutator and accessor functions for your class. Create a void function, outputDescription(), that outputs a textual description of the pizza object. Also include a function, computePrice(), that computes the cost of the pizza and returns it as a double according to the rules: Small pizza = $10 + $2 per topping Medium pizza = $14 + $2 per topping Large pizza = $17 + $2 per topping Write a suitable test program that creates and outputs a description and price of various pizza objects. Sample output (bolded text denote input from user) This pizza is: Small, Hand tossed, with 0 pepperoni toppings and 3 cheese toppings. Price of cheesy: 16 This pizza is: Large, Pan, with 2 pepperoni toppings and 1 cheese toppings. Price of pepperoni : 23 You may use the following main() function: int main() { Pizza cheesy; Pizza pepperoni; cheesy.setCheeseToppings(3); cheesy.setType(HANDTOSSED); cheesy.outputDescription(); cout << "Price of cheesy: " << cheesy.computePrice() << endl; pepperoni.setSize(LARGE); pepperoni.setPepperoniToppings(2); pepperoni.setType(PAN); pepperoni.outputDescription(); cout << "Price of pepperoni : " << pepperoni.computePrice() << endl; } Problem2: You operate several hot dog stands distributed throughout town. Define a class named HotDogStand that has a member variable for the hot dog stand's ID number and a member variable for how many hot dogs the stand has sold that day. Create a constructor that allows a user of the class to initialize both values. Also create a method named justSold() that increments the number of hot dogs the stand has sold by one. The idea is that this method will be invoked each time the stand sells a hot dog so that we can track the total number of hot dogs sold by the stand. Add another method that returns the number of hot dogs sold. Finally, add a static variable that tracks the total number of hotdogs sold by all hot dog stands and a static method that returns the value in this variable. Write a main method to test your class with at least three hot dog stands that each sells a variety of hot dogs. Sample output (bolded text denote input from user) Stand 1 sold 2 Stand 2 sold 1 Stand 3 sold 0 Total sold = 3 Stand 1 sold 3 Stand 2 sold 1 Stand 3 sold 1 Total sold = 5 You may use the following main() function: int main() { HotDogStand s1(1,0),s2(2,0),s3(3,0); s1.justSold(); s2.justSold(); s1.justSold(); cout << "Stand " << s1.getID() << " sold " << s1.getNumSold() << endl; cout << "Stand " << s2.getID() << " sold " << s2.getNumSold() << endl; cout << "Stand " << s3.getID() << " sold " << s3.getNumSold() << endl; cout << "Total sold = " << s1.getTotalSold() << endl; cout << endl; s3.justSold(); s1.justSold(); cout << "Stand " << s1.getID() << " sold " << s1.getNumSold() << endl; cout << "Stand " << s2.getID() << " sold " << s2.getNumSold() << endl; cout << "Stand " << s3.getID() << " sold " << s3.getNumSold() << endl; cout << "Total sold = " << s1.getTotalSold() << endl; return 0; }

Explanation / Answer

#1
import java.util.*;

Class Pizza
{

String size, type;
int pepperoni, cheese;

Public static void outputDescription(int type1, int size1, int pep1, int che1)
{

int topping_price= 2*pep1 + 2*che1;
int net_price;

switch (type1)
{
   case 1:
   Pizza.type= "deep dish";
   break;
   case 2:
   Pizza.type= "hand tossed";
   break;
   case 2:
   Pizza.type= "Pan";
   break;
   Delfault:
   Pizza.type = "No selection";
   break;
}


Switch (size1)
{
   case 1:
   net_price= 10 + topping_price;
   Pizza.size ="small";
   break;
   case 2:
   net_price= 14 + topping_price;
   Pizza.size ="medium";
   break;
   case 2:
   net_price= 17 + topping_price;
   Pizza.size ="large";
   break;
   Delfault:
   Pizza.type = "No selection";
   break;
}

if (pep1>che1)
{

   System.out.println("This pizza is:"+Pizza.size+"," +Pizza.type+", with" +pep1+ "pepperoni toppings and" +che1+    "cheese toppings.");
   System.out.println ("Price of Pepperoni"+net_price);

}

else
{

   System.out.println("This pizza is:"+Pizza.size+"," +Pizza.type+", with" +pep1+ "pepperoni toppings and" +che1+    "cheese toppings.");
   System.out.println ("Price of cheese"+net_price);

}

}

public static void main()
{
  
Scanner sc1= new Scanner();
System.out.println("Enter 1 for deep dish, 2 for hand tossed, or 3 for pan");
int type1 = sc1.nextInt();
System.out.println("Enter 1 for small, 2 for medium, or 3 for large");
int size1 = sc1.nextInt();
System.out.println("Enter number of pepproni");
int pep1 = sc1.nextInt();
System.out.println("Enter number of cheese");
int che1 = sc1.nextInt();


outputDescription(type1,size2,pep1,che1);

}

}

#2

// this prog is hard coded can have user defined numbers by scanner class

class HotDogStand
{
   static int net_sales=0;
   HotDogStand(String id, int number)
   {
       System. out.println(id +"sold"+number);
       net_sales= net_sales + number;
   }
   public static void main()
   {
       HotDogStand h1 = new HotDogStand("stand 1",7);  
       HotDogStand h2 = new HotDogStand("stand 2",5);
       HotDogStand h1 = new HotDogStand("stand 3",3);
  
       System.out.println("Total sold "+HotDogStand.net_sales);
   }
}          
  

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