This is a Java Program to Print Concentric Circles
We have to write a program in Java such that it prints five concentric circles in an applet using drawOval function of Graphics class.
For print concentric circles using applet, we can have the following set of input and output.
To view the concentric circles :
On the execution of the program, it is expected that five concentric circles are displayed in the applet.
1. Consider a radius for the smallest circle.
2. Draw five concentric circles using drawOval function of Graphics class.
Here is source code of the Java Program to print concentric circles using applet. The program is successfully compiled and tested using javac compiler on Fedora 30. The program output is also shown below.
/*Java Applet to Print Concentric Circles using Applet*/
public class Concentric extends Applet
//Initialize the applet
public void init()
//Draw cocentric circle
public void paint(Graphics g)
<applet code = Concentric.class width=500 height=500>
To execute the applet use the following commands:
>>>javac Concentric.java >>>appletviewer Concentric.java
1. To draw concentric circles use the drawOval(x,y,width,height) to draw an cirlce starting from the (x,y) co-ordinate of equal height and width.
2. Increment/decrement the parameters of drawOval for each circle.
Here’s the run time test cases to print concentric circles using Applet.
Sanfoundry Global Education & Learning Series – Java Programs.