Question: Modify the program 8-31 from page 584, 585 by adding the following: 1. Add a prototype before main() like: void bubbleSort(Circle [], int); 2. On

Modify the program 8-31 from page 584, 585 by adding the following:

1. Add a prototype before main() like: void bubbleSort(Circle [], int);

2. On line 21 add the following function call: bubbleSort(circle, SIZE);

3. After main() function add the definition for bublleSort() function similar to the one on page 628. Evidently you must change the Inventory data type with Circle.

The example in the textbook displays all the areas in order because the input is such that will cause the in order output. Your program should display all circles in order even when the input for radii is not in any particular order.

The program to be modified is below: (keep all the code in the same order)

Main.cpp

#include #include #include "Circle.h" // Circle class declaration file using namespace std;

const int NUM_CIRCLES = 4;

int main() { Circle circle[NUM_CIRCLES]; // Define an array of Circle objects

// Use a loop to initialize the radius of each object for (int index = 0; index < NUM_CIRCLES; index++) { double r; cout << "Enter the radius for circle " << (index + 1) << ": "; cin >> r; circle[index].setRadius(r); }

// Use a loop to get and print out the area of each object cout << fixed << showpoint << setprecision(2); cout << " Here are the areas of the " << NUM_CIRCLES << " circles. "; for (int index = 0; index < NUM_CIRCLES; index++) { cout << "circle " << (index + 1) << setw(8) << circle[index].findArea() << endl; } return 0; }

----

circle.h

// This header file contains the Circle class declaration.

#ifndef CIRCLE_H

#define CIRCLE_H

#include

class Circle

{ private:

double radius; // Circle radius

int centerX, centerY; // Center coordinates

public:

Circle() // Default constructor

{ radius = 1.0; // accepts no arguments

centerX = centerY = 0;

}

Circle(double r) // Constructor 2

{ radius = r; // accepts 1 argument

centerX = centerY = 0;

}

22 Circle(double r, int x, int y) // Constructor 3

23 { radius = r; // accepts 3 arguments

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!