1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
frosja888 [35]
3 years ago
7

Exercise1 : Defining Circle type and Creating a Driver Circle class private members double radius double xPos double yPos public

members double diameter() get the diameter of the Circle. It returns a value, diameter. double area() calculate the area of the Circle double circumference() calculate the circumference of the circle double getRadius() returns the radius double getX() returns the xPos value double getY() returns the yPos value void setX(double x) sets xPos, no requirements void setY(double y) sets yPos, no requirements double distanceToOrigin() returns the distance from the center of the circle to the origin HINT: Find out how to calculate the distance between two points and recall the origin is at (0,0) bool intersect(const Circle
Computers and Technology
1 answer:
asambeis [7]3 years ago
8 0

Answer:

Aee explaination

Explanation:

1) class_circle.h

#include<iostream>

#include<cmath>

#include<iomanip>

#define PI 3.14159

using namespace std;

class circle

{

private:

double radius,xPos,yPos;

public:

double diameter();

double area();

double circumference();

double getRadius();

double getX();

double getY();

void setX(double x);

void setY(double y);

double distanceToOrigin();

bool intersect(const circle& otherCircle);

bool setRadius(double r);

};

class CircleDriver:public circle

{

private:

circle circ1;

circle circ2;

void obtainCircles();

void printCircleInfo();

public:

void run();

};

2) class_circle.cpp

#include "class_circle.h"

double circle::diameter()

{

return (radius * 2);

}

double circle::area()

{

return PI * radius * radius;

}

double circle::circumference()

{

return 2 * PI * radius;

}

double circle::distanceToOrigin()

{

return sqrt((xPos * xPos) + (yPos * yPos));

}

double circle::getRadius()

{

return radius;

}

double circle::getX()

{

return xPos;

}

double circle::getY()

{

return yPos;

}

void circle::setX(double x)

{

xPos = x;

}

void circle::setY(double y)

{

yPos = y;

}

bool circle::setRadius(double r)

{

if(r > 0)

{

radius = r;

return true;

}

else

{

radius = 0;

return false;

}

}

bool circle::intersect(const circle& otherCircle)

{

double dist1 = (radius - otherCircle.radius) * (radius - otherCircle.radius);

double dist2 = ((xPos - otherCircle.xPos) * (xPos - otherCircle.xPos)) + ((yPos - otherCircle.yPos)*(yPos - otherCircle.yPos));

double dist3 = (radius + otherCircle.radius) * (radius + otherCircle.radius);

if((dist1 <= dist2 ) && (dist2 <= dist3) && (dist1 < dist3))

return true;

else

return false;

}

void CircleDriver::obtainCircles()

{

double x,y,rad;

cout<<"Enter xPos yPos circle 1 :";

cin>>x>>y;

do

{

cout<<"\n\nEnter radius for circle 1 :";

cin>>rad;

}while(rad <= 0);

circ1.setX(x);

circ1.setY(y);

circ1.setRadius(rad);

cout<<"\n\nEnter xPos yPos circle 2 :";

cin>>x>>y;

do

{

cout<<"\n\nEnter radius for circle 2 :";

cin>>rad;

}while(rad <= 0);

circ2.setX(x);

circ2.setY(y);

circ2.setRadius(rad);

}

void CircleDriver::printCircleInfo()

{

cout<<setprecision(6)<<endl;

cout<<"\n\nInformation for Circle 1:"<<endl;

cout<<"location:( "<<circ1.getX()<<" ,"<<circ1.getY()<<" )"<<endl;

cout<<"diameter: "<<circ1.diameter()<<endl;

cout<<"area: "<<circ1.area()<<endl;

cout<<"circumference: "<<circ1.circumference()<<endl;

cout<<"distance from the origin: "<<circ1.distanceToOrigin()<<endl;

cout<<"\n\nInformation for Circle 2:"<<endl;

cout<<"location:( "<<circ2.getX()<<" ,"<<circ2.getY()<<" )"<<endl;

cout<<"diameter: "<<circ2.diameter()<<endl;

cout<<"area: "<<circ2.area()<<endl;

cout<<"circumference: "<<circ2.circumference()<<endl;

cout<<"distance from the origin: "<<circ2.distanceToOrigin()<<endl<<endl;

if(circ1.intersect(circ2))

cout<<"The circles intersect."<<endl;

else

cout<<"The circles does not intersect."<<endl;

}

void CircleDriver::run()

{

obtainCircles();

printCircleInfo();

}

3) main.cpp

#include "class_circle.h"

int main()

{

CircleDriver myDriver;

myDriver.run();

return(0);

}

Please refer below output for reference

Enter xPos yPos circle 1 :0.0 50.0

Enter radius for circle 1 :100.0

Enter xPos yPos circle 2 :50.0 0.0

Enter radius for circle 2 :100.0

Information for Circle 1:

location:( 0 ,50 )

diameter: 200

area: 31415.9

circumference: 628.318

distance from the origin: 50

Information for Circle 2:

location:( 50 ,0 )

diameter: 200

area: 31415.9

circumference: 628.318

distance from the origin: 50

The circles intersect.

Process returned 0 (0x0) execution time : 18.245 s

Press any key to continue.

You might be interested in
Which cell has no nucleus ?​
Llana [10]
The answer is Prokaryotic Cell
5 0
3 years ago
Read 2 more answers
Tornado Alley is located in the middle of the United States, extending from Texas up through the Dakotas. The above statement is
Papessa [141]

Answer:

The above given statement is a fact.

Explanation:

A fact is nothing but a real statement which can never be false or imaginary or told in a future perspective. Let us analyze other options

Option 2: Opinion => An opinion can be anything and it can differ. A opinion is the way one people understand or perceive and give a statement according to that. An opinion always differs.

Option 3: Graphic => This is computer generated file, which can be true or false or imaginary. So this option is invalid

Option 4: Text => A text is nothing but words written together to convey a meaning. Though we feel like it suits the question, since the question speaks about the place, then it must definitely be fact and not just text.

4 0
2 years ago
Write a function named last_digit that returns the last digit of an integer. For example, last_digit(3572) should return 2. It s
Vika [28.1K]

def last_digit(num):

   num = str(num)

   return int(num[-1])

print(last_digit(-947))

I hope this helps!

6 0
3 years ago
User Interface Design ensures that the interface has elements that are easy to ________________. (Choose all that apply)
Gnesinka [82]

Answer:

A, C, D

Explanation:

User Interface (UI) Design focuses on anticipating what users might need to do and ensuring that the interface has elements that are easy to access, understand, and use to facilitate those actions.

4 0
2 years ago
Read 2 more answers
Identify the characteristics of logic problems. Select all that apply.
hoa [83]

Answer:

a problem that can be solved in a methodical manner

a problem solved with well-defined steps

6 0
2 years ago
Read 2 more answers
Other questions:
  • "Server Manager will allow you to manage all roles and features installed on any server, and view the status of all your servers
    7·1 answer
  • An analyst is reviewing the logs from the network and notices that there have been multiple attempts from the open wireless netw
    13·1 answer
  • Which rule should be followed to stay safe online
    5·1 answer
  • 1. Which of the following statements are true about routers and routing on the Internet. Choose two answers. A. Protocols ensure
    9·2 answers
  • What means the data is still saved even if you turn the computer off or unplug it?​
    5·1 answer
  • Which statements about grades are accurate? Check all that apply. Grades help indicate how well a student is understanding a cer
    13·1 answer
  • Es la actividad que posibilita comunicar gráficamente ideas, hechos y valores procesados y sintetizados en términos de forma y c
    11·1 answer
  • Overview In this assignment, you will gain more practice with designing a program. Specifically, you will create pseudocode for
    7·1 answer
  • Brainly Question
    14·2 answers
  • What product use programmable control?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!