Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Dont know what goes in my main file I have the cpp file of Circle class and head

ID: 3841708 • Letter: D

Question

Dont know what goes in my main file I have the cpp file of Circle class and header File of Circle class. This program is in c++

// header file of cirlce class

#ifndef CIRCLE_H
#define CIRLCE_H

class Circle
{
public:
Circle();
Circle(double);
double getArea() const;
double getRadius() const;
void setRadius(double);
static int getNumberOfObjects();
bool operator <(const Circle& other);
bool operator <=(const Circle& other);
bool operator ==(const Circle& other);
bool operator !=(const Circle& other);
bool operator >(const Circle& other);
bool operator >=(const Circle& other);

private:
double radius;
static int numberOfObjects;
};
#endif

// cpp file of circle class

include "Circle.h"

Circle::Circle(){
radius = 0;
numberOfObjects++;
}
int Circle::numberOfObjects = 0;
Circle::Circle(double r){
radius = r;
numberOfObjects++;
}
double Circle::getArea() const{
return 3.14*radius*radius;
}
double Circle::getRadius() const{
return radius;
}
void Circle::setRadius(double r){
radius = r;
}
int Circle::getNumberOfObjects(){
return numberOfObjects;
}
// overloaded < operator
bool Circle::operator <(const Circle& other) {
if(radius < other.radius) {
return true;
}else
return false;
}
// overloaded <= operator
bool Circle::operator <=(const Circle& other) {
if(radius <= other.radius) {
return true;
}else
return false;
}
// overloaded == operator
bool Circle::operator ==(const Circle& other) {
if(radius == other.radius) {
return true;
}else
return false;
}
// overloaded != operator
bool Circle::operator !=(const Circle& other) {
if(radius != other.radius) {
return true;
}else
return false;
}
// overloaded > operator
bool Circle::operator >(const Circle& other) {
if(radius > other.radius) {
return true;
}else
return false;
}
// overloaded >= operator
bool Circle::operator >=(const Circle& other) {
if(radius >= other.radius) {
return true;
}else
return false;
}

// My main file

#include <iostream>
#include "Rational.h"
#include "StackOfIntegers.h"
#include "Circle.h"
#include <string>
using namespace std;

void Prog14_1()
{
double sum = 0;
//Use for loop block to create objects and invoke functions for 100 times.
for(int i = 1; i < 100; i++)
{
//Pass arguments to functions
Rational x (i, i+1);
//Function to print the series value
x. print_fraction();
//Function to calculate summation value
sum = sum + x.ret_floating ();
}
cout << " Summation value is: " << sum;

}

void Prog14_2()
{
// Create and initialize two rational numbers r1 and r2.
Rational r1(4, 2);
Rational r2(2, 3);

// Test toString, add, substract, multiply, and divide
cout << r1.toString() << " + " << r2.toString() << " = "
    << r1.add(r2).toString() << endl;
cout << r1.toString() << " - " << r2.toString() << " = "
    << r1.subtract(r2).toString() << endl;
cout << r1.toString() << " * " << r2.toString() << " = "
    << r1.multiply(r2).toString() << endl;
cout << r1.toString() << " / " << r2.toString() << " = "
    << r1.divide(r2).toString() << endl;

// Test intValue and double
cout << "r2.intValue()" << " is " << r2.intValue() << endl;
cout << "r2.doubleValue()" << " is " << r2.doubleValue() << endl;

// Test compareTo and equal
cout << "r1.compareTo(r2) is " << r1.compareTo(r2) << endl;
cout << "r2.compareTo(r1) is " << r2.compareTo(r1) << endl;
cout << "r1.compareTo(r1) is " << r1.compareTo(r1) << endl;
cout << "r1.equals(r1) is " << r1.equals(r1) << endl;
cout << "r1.equals(r2) is " << r1.equals(r2) << endl;

}

void Prog14_3()
{


}

void Prog14_4()
{
StackOfIntegers s;
s.push(1);
s.push(2);

s[0] = 999;

cout << s[0] << endl;

}

void Prog14_7()
{


}


int main()
{

       while (true)
       {
              system("cls");
              cout << " Main Menu - Chapter 14" << endl;
              cout << "==============================" << endl;
              cout << " 1: Programming Exercise 14.1" << endl;
              cout << " 2: Programming Exercise 14.2" << endl;
              cout << " 3: Programming Exercise 14.3" << endl;
              cout << " 13: Programming Exercise 14.4" << endl;
              cout << " 16: Programming Exercise 14.7" << endl;
              cout << "other: Exit" << endl;
              cout << "==============================" << endl;
              cout << "Enter an exercise: ";
              char exercise[2];
              cin >> exercise;
              cout << endl;
              switch (atoi(exercise))
              {
                     case 1: Prog14_1(); break;
                     case 2: Prog14_2(); break;
                     case 3: Prog14_3(); break;
                     case 4: Prog14_4(); break;
                     case 7: Prog14_7(); break;
            
                     default: exit(0);
              }
              cout << endl;
              system("pause");
              cin.clear();
       }

       return 0;
}

14.3 (The Circle class) Implement the relational operators st) in the Circle class in Listing 10.9, CircleWithConstantMemberFunctions.h, to order the Circle objects according to their radii.

Explanation / Answer

Since you have already implemented <= operator in Cicle class.
You can use operator <= to order the circles according to their radii in function Prog14_3().

Steps:
Using overloaded operators <, <=, > and >=,

Without using overloading

bool comp(Circle c1, Circle c2)
{
return (c1.radius < c2.radius);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote