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

I am having trouble with the price. I set it to 5 just to see if I can get it di

ID: 3678481 • Letter: I

Question

I am having trouble with the price. I set it to 5 just to see if I can get it displayed correctly in the output. But I am still having problems entirely. I would like the code to be kept as close to what I have as possible.

//Gavin Jones
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
using namespace std;


class Pizza
{
private:
   int _pizzaSize;
   int _type;
   int _toppings;
   double _price;
public:
   Pizza();
   Pizza(int pizzaSize, int type, int toppings);
  
   void setType(int type);
   void setPizzaSize(int pizzaSize);
   void totalToppings(int toppings);
   void totalPrice(int toppings, double price);
  
   void outputDescription();

};

Pizza::Pizza()
{
   _pizzaSize = 0;
   _toppings = 0;
   _type = 0;
   _price = 0;
};

Pizza::Pizza(int pizzaSize, int type, int toppings)
{
   _pizzaSize = pizzaSize;
   _type = type;
   _toppings = toppings;
};

void Pizza::setPizzaSize(int pizzaSize)
{
   _pizzaSize = pizzaSize;
};

void Pizza::setType(int type)
{
   _type = type;
};

void Pizza::totalToppings(int toppings)
{
   _toppings = toppings;
};

void Pizza::totalPrice(int toppings, double price)
{
   _price = 5;
      
};


void Pizza::outputDescription()
{
   cout << "Type: ";
   if (_type >= 1 && _type <= 3)
   {
       switch (_type)
       {
       case 1:
           std::cout << "Deep Dish" << endl;
           break;

       case 2:
           std::cout << "Hand Tossed" << endl;
           break;
       case 3:
           std::cout << "Pan" << endl;
           break;

       }
   };


   cout << "Size: ";
   if (_pizzaSize >= 1 && _pizzaSize <= 3)
   {
       switch (_pizzaSize)
       {
       case 1:
           std::cout << "Small)" << endl;
           break;

       case 2:
           std::cout << "Medium" << endl;
           break;
       case 3:
           std::cout << "Large" << endl;
           break;

       }
   };


      
  
   cout << "Number of toppings: " << _toppings << endl;
   cout << &Pizza::totalPrice;
};


int main()
{

   int pizzaSize,toppings;
   int type;
  
   cout << "What type of pizza do you want? " << endl
       << "1 for Deep Dish ($10.25)" << endl
       << "2 for Hand Tossed ($14.50)" << endl
       << "3 for Pan ($17.75)" << endl
       << "Enter corresponding number: ";
   cin >> type;

   cout << endl << "What size pizza do you want? " << endl
       << "1 for Small" << endl
       << "2 for Medium" << endl
       << "3 for Large" << endl
       << "Enter corresponding number: ";
   cin >> pizzaSize;
   cout << "How many toppings ($2.50 each) would you like? ";
  
   cin >>toppings;

   Pizza pizzaOne(pizzaSize, type,toppings); //these are the original values
   pizzaOne.outputDescription();

  

   //prints value fortoppings after each function

   return 0;
};

3. Pizza class Define a class called Pizza that has member variables to track the type of pizza (deep dish, hand tossed, or pan) along with size (small, medium, large) and the number of toppings. You can use constants to represent the type and size. Include appropriate constructors, mutator and accessor methods for the class. Create a void function called outputDescription that outputs a textual description of the pizza object. Also include a function called computePrice that computes the cost of the pizza and returns a double Use the following table for pricing rules Small pizza Medium pizza Large pizza $10.25 plus $2.50 per topping $14.50 plus $2.50 per topping $17.75 plus $2.50 per topping

Explanation / Answer

Hi i have written the code for your reference.