Question
Create a NetBeans project named CPS150_Lab13 . Copy-and-paste the highlighted code below into the main method of your new CPS150_Lab13 class. Complete the following code
Create a NetBeans project named CPS150_Lab13.
Copy-and-paste the highlighted code below into the main method of your new CPS150_Lab13 class.
Complete the following code to test whether two circles, each having a user-defined radius and a fixed center point lying along the same horizontal line, are disjoint, overlapping, or mutually contained.
public class CPS150_Lab13 { public static void main(String[] args) { Scanner in = new Scanner(System.in); // red circle variables int red_radius = 0; int red_centerX = 0; // no red_centerY since circles are aligned on the x-axis int red_left_point = 0; // point on x-axis intersected by left edge int red_right_point = 0; // point on x-axis intersected by right edge // blue circle variables int blue_radius = 0; int blue_centerX = 0; // no blue_centerY since circles are aligned on the x-axis int blue_left_point = 0; // point on x-axis intersected by left edge int blue_right_point = 0; // point on x-axis intersected by right edge /* * get the radius and center point x-coordinate * for the red circle */ System.out.print("Input the radius of the red circle: "); red_radius = in.nextInt(); System.out.print("Input the x-coordinate of the red circle's center point: "); red_centerX = in.nextInt(); /* * get the radius and center point x-coordinate * for the blue circle */ System.out.print("Input the radius of the blue circle: "); blue_radius = in.nextInt(); System.out.print("Input the x-coordinate of the blue circle's center point: "); blue_centerX = in.nextInt(); /* * for each circle, calculate the points where the left * and right edges intersect the x-axis * * *** ADD CODE HERE *** */ /* * determine and output the relationship between * the red and blue circles as one of: * i. circles are disjoint * ii. red circle is contained in blue circle * iii. blue circle is contained in red circle * iv. circles are overlapping * * *** ADD CODE HERE *** */ } // end main method } // end class CPS150_Lab13
Sample Runs (user input in red):
Input the radius of the red circle: 10 Input the x-coordinate of the red circle's center point: 0 Input the radius of the blue circle: 15 Input the x-coordinate of the blue circle's center point: 40 circles are disjoint Input the radius of the red circle: 15 Input the x-coordinate of the red circle's center point: 50 Input the radius of the blue circle: 20 Input the x-coordinate of the blue circle's center point: 0 circles are disjoint Input the radius of the red circle: 10 Input the x-coordinate of the red circle's center point: 20 Input the radius of the blue circle: 40 Input the x-coordinate of the blue circle's center point: 30 red circle is contained in blue circle Input the radius of the red circle: 10 Input the x-coordinate of the red circle's center point: 20 Input the radius of the blue circle: 20 Input the x-coordinate of the blue circle's center point: 30 red circle is contained in blue circle Input the radius of the red circle: 40 Input the x-coordinate of the red circle's center point: 20 Input the radius of the blue circle: 10 Input the x-coordinate of the blue circle's center point: 30 blue circle is contained in red circle Input the radius of the red circle: 20 Input the x-coordinate of the red circle's center point: 20 Input the radius of the blue circle: 10 Input the x-coordinate of the blue circle's center point: 30 blue circle is contained in red circle Input the radius of the red circle: 10 Input the x-coordinate of the red circle's center point: 0 Input the radius of the blue circle: 15 Input the x-coordinate of the blue circle's center point: 10 circles are overlapping Input the radius of the red circle: 10 Input the x-coordinate of the red circle's center point: 10 Input the radius of the blue circle: 15 Input the x-coordinate of the blue circle's center point: 0 circles are overlapping
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started