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

Java Applet: Write an applet that displays four concentric circles. Each circle

ID: 3813715 • Letter: J

Question

Java Applet: Write an applet that displays four concentric circles. Each circle should have a lighter shade of the same color.(HINT: Look uo the brighter method in the Color class.)

This is my code but I am not getting the lighter shade of color.

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;

public class ConcentricCircles extends Applet {
  
public void paint(Graphics g2)
{   
super.paint(g2);
setBackground(Color.lightGray);
int X=30; //radius of circle
int Y=X*2; //diameter
int r = 105, g = 105, b = 105;
Color rgb = new Color(r,g,b);
for(int i=0;i<4;i++)
{
g2.setColor(rgb.brighter());
g2.drawOval(100-(i*X),100-(i*X),50+(i*Y),50+(i*Y));
}
}
}

Explanation / Answer


import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
public class ConcentricCircles extends Applet {
  
public void paint(Graphics g2)
{   
super.paint(g2);
//setBackground(Color.lightGray);
int X=30; //radius of circle
int Y=X*2; //diameter
int r = 105, g = 105, b = 10;
Color rgb = new Color(r,g,b);
  
for(int i=0;i<4;i++)
{
rgb=rgb.brighter();
g2.setColor(rgb);
g2.drawOval(100-(i*X),100-(i*X),50+(i*Y),50+(i*Y));
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote