Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include "Circle.h" // Circle class declaration file
- using namespace std;
- void sortArray(int [], int);
- void showArray(const int [], int);
- int main()
- {
- const int NUM_CIRCLES = 7;
- Circle circle[NUM_CIRCLES] = {2.5, 4.0, 1.0, 3.0, 6.0, 5.5, 2.0 }; // 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 << "The radius for circle " << (index+1) << ": "<<endl;
- showArray(circle, NUM_CIRCLES);
- circle[index].setRadius(r);
- }
- // Use a loop to get and print out the area of each object
- cout << fixed << showpoint << setprecision(2);
- cout << "\nHere are the areas of the " << NUM_CIRCLES
- << " circles.\n";
- for (int index = 0; index < NUM_CIRCLES; index++)
- { cout << "circle " << (index+1) << setw(8)
- << circle[index].findArea() << endl;
- }
- return 0;
- }
- void sortArray(int array[],int size)
- {
- int temp;
- bool madeAswap;
- do
- {
- madeAswap = false;
- for (int count = 0; count < (size - 1); count++)
- {
- if (array[count] > array[count + 1])
- {
- temp = array[count];
- array[count] = array[count + 1];
- array[count + 1] = temp;
- madeAswap = true;
- }
- }
- } while (madeAswap);
- }
- void showArray(const int array[], int size)
- {
- for (int count = 0; count < size; count++)
- cout<<array[count]<<" ";
- cout<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement