Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write class declaration for a class named Pizza that has the data members price, a double, and size, a Circle object (FROM 7.10 MINI-PROGRAMMING PROJECT

Write class declaration for a class named Pizza that has the data members price, a double, and size, a Circle object (FROM 7.10 MINI-PROGRAMMING PROJECT A). It also has member functions: setPrice() which sets the data member price, setSize() which sets the Circle data member, and costPerSqln() which returns the double value that is the cost per square inch of the pizza. Write the code for these as inline functions. Your Pizza class will also need to have a default constructor which has no parameters and sets the price to $5.00 and the size to a radius of 6. It will also have another constructor which accepts two parameters: P for price and S for size. Write main() program that makes two Pizza objects to test out the two constructors. The main() program also needs to test out the setPrice(), setSize(), and costPerSqIn() member functions.

This is 7.10 Mini-program. I did.

#include

using namespace std;

#define Pi 3.1416

//Estimated value of Pi

class Circle

{

private:

double radius;

public:

Circle()

{radius=1;}

Circle(double i)

{radius=i;}

void setRadius(double r)

{ radius= r;}

double getRadius()

{ return radius;}

double calcArea()

{return Pi * radius * radius;}

double calcDiameter()

{return radius * 2;}

double calcCircumference()

{return Pi * radius * 2;}

};

int main() {

Circle c;

cout <<"circle area: " <

cout <<"circle diameter: "<

cout << "circle Circumference = "<< c.calcCircumference() << endl;

c.setRadius(10.0);

cout <<"circle area: " <

cout <<"circle diameter: "<

cout << "circle Circumference = "<< c.calcCircumference() << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

how a district manager performs the functions of management

Answered: 1 week ago