Need HELP on THIS PLEASE!!!!!!
I'm stuck and I hate this. Someone help me out please.
Write a graphics program that asks the user to specify the radii of two circles. The first circle has center (100,200), and the second circle has center(200,100). Draw the circles. If they intersect, then display a message "Circles intersect." Otherwise, display "Circles don't intersect." Hint: Compute the distance between the centers and compare it to the radii. Your program should draw nothing if the user enters a negative radius.
I need a Circle.java file and a CircleIntersectApplet.java file.
Here is what I have so far:
public class CircleIntersectApplet extends Applet
String input1 = JOptionPane.showInputDialog("Enter the Radius of the first circle");
init_radius1 = Integer.parseInt(input1);
String input2 = JOptionPane.showInputDialog("Enter the Radius of the second circle");
init_radius2 = Integer.parseInt(input2);
public void paint(Graphics g)
Graphics2D g2 = (Graphics2D)g;
final double x1Center = 100; //Fixed Center Point
final double y1Center = 200; //Fixed Center Point
final double x2Center = 200; //Fixed Center Point
final double y2Center = 100; //Fixed Center Point
double radius1 = init_radius1;
double radius2 = init_radius2;
//Draws the first circle
= new Ellipse2D.Double(x1Center - radius1, y1Center - radius1, 2 * radius1, 2 * radius1);
//Draws the second circle
= new Ellipse2D.Double(x2Center - radius2, y2Center - radius2, 2 * radius2, 2 * radius2);
private final double init_radius1;
private final double init_radius2;
When this is ran in an Appletviewer, it asks the User to input the First radius, then the Second Radius. After it is inputed, it draws two circles with the inputed Radius'.
Now, I still need the if statements to compute the distance between the two centers = d, and the two Radius = r1 and r2.
something like: if d > r1 + r2 then they don't intersect.
I don't know how to write If else statements and don't know where I should plug it in.
Also, I have to submit in 2 files... not 1. So I don't know what should be in the first file and the second one.
Lastly, if they do intersect, it needs to say "Circles intersect." and if they don't intersect, it needs to say "Circles don't intersect." in the applet with the 2 circles showing.
Please help. I've been on my *** tryin to do this for hours now...
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center