2.2 Draw ten red circles in a vertical column in the center of the applet

VerticalCircles.java

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Dimension;
/*
<applet code="VerticalCircles.class" height=400 width=800>
</applet>
*/
public class VerticalCircles extends Applet
{
public void paint(Graphics g)
{
//int x=50, y=50;
Dimension d=getSize();
int x=d.width/2;
int y=d.height/2;
g.setColor(Color.red);
for(int i=0;i<10;i++) //y+=55
{
//g.fillOval((w-x)/2,y,55,55);
g.fillOval(x,i*50,50,50);
}
}
}

Output



Happy Coding :)