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: 3614216 • 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

The main method is a method - you cannot put it outside of aclass. If you insist on using only one class, include themain method inside of the Circles class. importjava.util.*; import java.awt.*; import javax.swing.*; class Circles extends JComponent { private int r1, r2; public Circles(int r1, int r2) { setPreferredSize(new Dimension(500, 500)); this.r1 =r1; this.r2 =r2; } public void paintComponent(Graphics g) { // check for intersection // minimum distance between two circles is100 sqrt (2) by Pythagorean Theorem if(r1+r2>=100*Math.sqrt(2)) { g.setColor(Color.green); } else { g.setColor(Color.black); } // draw circles g.drawOval(100, 200, r1, r1); g.drawOval(200, 100, r2, r2); } publicstatic void 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