Question





lett CHAPTER SECTION 76 WRITE A C++ PROGRAMY TO CREATE A CLASS CALLER PIZZA WITH THE FOLLOWING MEMBERS AND FUNCTIONS: CLASS-P
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks

#include<iostream>

using namespace std;

//Pizza class

class Pizza{

                double price; //price of pizza in dollars

                double size; //radius of pizza in inches

public:

                //constructor initializing both values to 0

                Pizza(){

                                price=0;

                                size=0;

                }

                //setters and getters for price and size

                void setPrice(double p){

                                price=p;

                }

                void setSize(double s){

                                size=s;

                }

                double getPrice(){

                                return price;

                }

                double getSize(){

                                return size;

                }

                //returns the cost per square inches

                double getPricePerSqIn(){

                                //using 3.1415926535 as value of pi

                                double PI=3.1415926535;

                                //finding total area

                                double area=PI*size*size;

                                //dividing price by area to get price per sq inch

                                double pricePerSqIn=price/area;

                                return pricePerSqIn;

                }

};

int main(){

                //creating a Pizza object

                Pizza pizza;

                double input;

               

                //asking, reading and setting price

                cout<<"Enter the price of Pizza: ";

                cin>>input;

                pizza.setPrice(input);

               

                //asking, reading and setting size in radius

                cout<<"Enter the size (radius, not diameter) of Pizza: ";

                cin>>input;

                pizza.setSize(input);

               

                //displaying price per square inches.

                cout<<"Price Per Square Inch: $"<<pizza.getPricePerSqIn()<<endl;

                return 0;

}

/*OUTPUT*/

Enter the price of Pizza: 150

Enter the size (radius, not diameter) of Pizza: 12

Price Per Square Inch: $0.331573

Add a comment
Know the answer?
Add Answer to:
lett CHAPTER SECTION 76 WRITE A C++ PROGRAMY TO CREATE A CLASS CALLER PIZZA WITH THE...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Visul Studio Create a class named Vehicle. The class has the following five member variables:...

    C++ Visul Studio Create a class named Vehicle. The class has the following five member variables: • Vehicle Name • Vehicle number • Sale Tax • Unit price • Total price Include set (mutator) and get (accessor) functions for each field except the total price field. The set function prompt the user for values for each field. This class also needs a function named computePrice() to compute the total price (quantity times unit price + salesTax) and a function to...

  • Create a class Circle with one instance variable of type double called radius. Then define an...

    Create a class Circle with one instance variable of type double called radius. Then define an appropriate constructor that takes an initial value for the radius, get and set methods for the radius, and methods getArea and getPerimeter. Create a class RightTriangle with three instance variables of type double called base, height, and hypotenuse. Then define an appropriate constructor that takes initial values for the base and height and calculates the hypotenuse, a single set method which takes new values...

  • Please help with this assignment. Thanks. 1. Write a C++ program containing a class Invoice and...

    Please help with this assignment. Thanks. 1. Write a C++ program containing a class Invoice and a driver program called invoiceDriver.cpp. The class Invoice is used in a hardware store to represent an invoice for an item sold at the store. An invoice class should include the following: A part number of type string A part description of type string A quantity of the item being purchased of type int A price per item of type int A class constructor...

  • In C++ Write a program that contains a BankAccount class. The BankAccount class should store the...

    In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...

  • In c++ Write a program that contains a class called Player. This class should contain two...

    In c++ Write a program that contains a class called Player. This class should contain two member variables: name, score. Here are the specifications: You should write get/set methods for all member variables. You should write a default constructor initializes the member variables to appropriate default values. Create an instance of Player in main. You should set the values on the instance and then print them out on the console. In Main Declare a variable that can hold a dynamcially...

  • C++ Exercice Topic Cover: Class and main implementation 1. Created the class circle.h file 2. Create...

    C++ Exercice Topic Cover: Class and main implementation 1. Created the class circle.h file 2. Create the Circle. cpp 3. Create the main function and use the class Circle in your program (CircleClass) Create a class called circle in other to performing the calculation of the area, sectional area and circumference of any circle. Write a program to test your class. Circle Use double variables to represent the private data of the class. Provide a constructor that enables an object...

  • please use c++ Write a program that contains a class Rectangle with two private double precision...

    please use c++ Write a program that contains a class Rectangle with two private double precision members iLength and iWidth, public set and get member functions for these two members, a two argument constructor that sets the length and width to any two user specified values and a void function area() that computes the area and then prints this value by inserting it into the cout output stream. Write a main function that ereates a Rectangle with a length of...

  • USE!! PYTHON!!! Programming:   Pizza 1. Write a Pizza class to that this client code works. Please...

    USE!! PYTHON!!! Programming:   Pizza 1. Write a Pizza class to that this client code works. Please note that it is ok if the toppings are listed in a different order. >>> pie = Pizza() >>> pie Pizza('M',set()) >>> pie.setSize('L') >>> pie.getSize() 'L' >>>pie.addTopping('pepperoni') >>>pie.addTopping('anchovies') >>>pie.addTopping('mushrooms') >>> pie Pizza('L',{'anchovies', 'mushrooms', 'pepperoni'}) >>>pie.addTopping('pepperoni') >>> pie Pizza('L',{'anchovies', 'mushrooms', 'pepperoni'}) >>>pie.removeTopping('anchovies') >>> pie Pizza('L',{'mushrooms', 'pepperoni'}) >>> pie.price() 16.65 >>> pie2 = Pizza('L',{'mushrooms','pepperoni'}) >>> pie2 Pizza('L',{'mushrooms', 'pepperoni'}) >>> pie==pie2 True The Pizza class should have...

  • Use your Car class from the previous Programming Assignment. For this assignment, create a new class...

    Use your Car class from the previous Programming Assignment. For this assignment, create a new class that represents a Used Car Dealership. Your Java program will simulate an inventory system for the dealership, where the employees can manage the car information. Start by creating an array of 10 cars, with an "ID" of 0 through 9, and use the default constructor to create each car. For example, the third car in an array called cars would have ID 2. You...

  • OBJECT ORIENTED PROGRAMMING C++ B- The programming section has 2 parts: Part 1 - Create a...

    OBJECT ORIENTED PROGRAMMING C++ B- The programming section has 2 parts: Part 1 - Create a class - (35 points) Create a class called CustomDressInvoice. It should have 5 data members: designTime (int), designRate (int), sewing Time (int), sewingRate (int), and materialsCost. The invoice amount is calculated with this formula: Invoice Amount = (designTime * designRate) + (sewingTime * sewing Rate) + materialCost All times are charged by the hours, and rates are charged by the dollars (no cents). The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT