Question: 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
Get step-by-step solutions from verified subject matter experts
