Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is what I was told to do. This is for my biology researchproject where we a

ID: 3614215 • Letter: H

Question

Here is what I was told to do. This is for my biology researchproject where we are studying the way the human brain choosesnumbers.
I need to write this in java.

Ineed to write a graphics program that asks the user to specify theradii for two circles of center (100, 200) and (200,100). Than javaneeds to draw the two circles with the appropriate radii. If theyintersect than they must both be green. If someone writes anegative radii it should say invalid input.
I need to write this in java.

Ineed to write a graphics program that asks the user to specify theradii for two circles of center (100, 200) and (200,100). Than javaneeds to draw the two circles with the appropriate radii. If theyintersect than they must both be green. If someone writes anegative radii it should say invalid input.

Explanation / Answer

First let us create a component sub-class fordrawing the circles. class Circlesextends JComponent { privateint r1, r2; publicCircles(int r1, int r2) { setPreferredSize(new Dimension(500, 500)); this.r1 = r1; this.r2 = r2; } publicvoid paintComponent(Graphics g) { //check for intersection //minimum distance between two circles is 100 sqrt (2) by PythagoreanTheorem if(r1+r2>=100*Math.sqrt(2)) { g.setColor(Color.black); } else { g.setColor(Color.green); } //draw circles g.drawOval(100, 200, r1,r1); g.drawOval(200, 100, r2,r2); } } Now we can write a main method to input radiiand draw the circles. public staticvoid main(String[] args) { // input Scanner input= newScanner(System.in); int r1= 0, r2 =0; do { System.out.print("Enterradius of first circle :: "); r1 = input.nextInt(); if(r1