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 of the following statements is true?
diamong [38]
The correct answer is d
8 0
3 years ago
1. A database table can hold ??
IRINA_888 [86]

Answer:

who are interested and I have been trying to

3 0
3 years ago
Explain
Charra [1.4K]

Answer:

The main difference between LAN, MAN and WAN is the scope and coverage of the networks. LAN (Local area network) is usually used to connect computers in smaller distances such as in a building or in offices. They use various topologies such as bus topology, ring topology, star typology etc to connect the computers and share information only among the computers connected in LAN. A Metropolitan Network covers larger coverage than LAN and is usually used for connecting a city rather than single organization. A Wide Area Network is collection of networks or many LANS. The perfect example of WAN is internet which connects thousands and millions of networks. Another factor which distinguishes between LAN, MAN and WAN is that LAN and MAN are owned by certain entities such as government, educational institutions or organizations whereas WAN (i.e. Internet) is not owned by anyone.

4 0
2 years ago
In the broadest of terms, the performance management process features a cycle that begins with ________________ and concludes wi
Flauer [41]

In the broadest of terms, the performance management process features a cycle that starts with Prerequisites and concludes with performance Review.

<h3>What is performance management process?</h3>

Performance management exists as a communication procedure by which managers and employees work together to plan, monitor, and review an employee's work goals and overall contribution to the organization. Effective performance management exists important to businesses. Through both formal and informal processes, it allows them to align their employees, resources, and systems to complete their strategic objectives.

<h3> Steps of the performance process</h3>
  • Step 1: Create a Performance Management Plan. Create the plan as described as possible, avoiding the usage of ambiguous language.
  • Step 2: Set Goals for Performance Management.
  • Step 3: Complete a Performance Review System.
  • Step 4: Create Strong Feedback-Giving Skills.
  • Step 5: Ongoing Employee Performance Management.

Hence, In the broadest of terms, the performance management process features a cycle that starts with Prerequisites and concludes with performance Review.

To learn more about performance management process refer to:

brainly.com/question/14506325

#SPJ4

3 0
1 year ago
What term is used to identify the visual interface that displays information it receives from the computer?
olga nikolaevna [1]
The answer to this question is A
7 0
3 years ago
Other questions:
  • Which computer port transmits audio and video without the need for compression?
    6·1 answer
  • Which of the following represents inbound logistics for a bookstore
    13·1 answer
  • A user states that when they power on their computer, they receive a "Non-bootable drive" error. The user works with external st
    8·1 answer
  • Enterprise Resource Planning (ERP) is an example of a single user database.
    7·1 answer
  • Angela recently purchased a new Android smartphone. While purchasing the phone, Angela was told that she would need to set up a
    14·1 answer
  • In client server network, there is no central server //// true or false​
    8·1 answer
  • Which part of a touchscreen responds to pressure applied to its surface?
    6·1 answer
  • (Print distinct numbers) Write a program that reads in integers separated by a space in one line and displays distinct numbers i
    8·1 answer
  • Mention any
    14·1 answer
  • How will you maintain electrical tools and equipment?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!