Question: In this exercise, you modify the pizza slices program shown in Figure 15-10 in the chapter. If necessary, create a new project named ModifyThis10 Project

In this exercise, you modify the pizza slices program shown in Figure 15-10 in the chapter. If necessary, create a new project named ModifyThis10 Project and save it in the Cpp8\Chap15 folder. Enter the C++ instructions from the figure into a source file named ModifyThis10.cpp. Change the filename in the first comment. Enter the instructions shown in Figure 15-8 in the chapter in a header file named ModifyThis10 Square.h. Change the filename in the first comment. Modify the pizza slices program so it uses the parameterized constructor in the ModifyThis10 Square.h file. Test the program appropriately.

1 //Pizza Slices.cpp 2 //Displays the number of square slices 3 //that can be cut from a square pizza 4 //Created/revised by  on  5 6 #include  7 #include

1 //Pizza Slices.cpp 2 //Displays the number of square slices 3 //that

1 //Pizza Slices.cpp 2 //Displays the number of square slices 3 //that can be cut from a square pizza 4 //Created/revised by on 5 6 #include 7 #include "Modified Square.h" 8 using namespace std; 9. 10 int main() 11 { //instantiate Square objects Square wholePizza; Square pizzas1ice; // declare variables 12 13 14 15 double wholesi de = 0.0; double sliceSide = 0.0; double wholeArea = 0.0; double sliceArea = 0.0; double numSlices = 0.0; 16 17 18 19 20 21 //get side measurements cout "Whole pizza side measurement (inches): "; cin > wholeside; cout "Pizza siice side measurement (inches): "; cin sliceside; 22 23 24 25 26 27 //assign side measurements to Square objects wholePizza.setSide (wholeSide); pizzaslice.setSide(sliceSide); 28 29 30 31 //calculate areas wholeArea = wholePizza.calcArea(); sliceArea = pizzaslice.calcArea(); 32 33 34 35 //calculate number of slices if (sliceArea > 0.0) numSlices = wholeArea / sliceArea; //end if cout

Step by Step Solution

3.45 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

ModifyThis10cpp Displays the number of square slices that can be cut from a squa... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related An Introduction Programming Questions!