Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a program that finds whether a point is in a circle . The program should include a Point class which includes the x

C++

Write a program that finds whether a point is in a circle. The program should include a Point class which includes the x and y coordinates as integers. There should be a Circle class which consists of its center point (x and y coordinates) and the radius as integers.

Write the Point and the Circle classes

Define a function called distance as a member function in Circle class to calculate the distance between center point of the circle and a point. The distance function should report if the point is in the circle or not

In the main, define Point and Circle objects

In the main program, ask user to enter x, y coordinates and radius of the circle if radius is less than zero throw an exception from the input stream operator. Overload input stream operator.

If it is not less than zero, ask for the x and y coordinates of the point . Overload input stream operator.

In the main, call distance function and display the message as given in the sample run

Distance formula is given below:

Sample Run:

Enter center coordinates of the circle: 2 3

Enter radius of the circle: 4

Enter coordinates of the point: 1 2

Point is in the circle

Sample Run:

Enter center coordinates of the circle: 2 3

Enter radius of the circle: -5

Invalid radius!

Sample Run:

Enter center coordinates of the circle: 2 3

Enter radius of the circle: 4

Enter coordinates of the point: 8 9

Point is not in the circle

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+4. Descriptive statistics_ tistics while inferential sta-

Answered: 1 week ago