import java.applet.*; import java.awt.*; public class Loops extends Applet { public Font myFont; public void init() { myFont=new Font("Helvetica", Font.PLAIN, 20); setFont(myFont); setBackground(Color.black); setForeground(Color.red); } public void paint(Graphics g) { for(int i=0; i < 5; i++) { // the variable i gets automatically incremented after every // iteration of the for loop g.drawString("Carman", 25, 25+(i*20)); } g.setColor(Color.blue); int counter=0; while (counter < 5) { // the condition for this loop is tested at the start of the loop // the loop may not run once g.drawString("Carman", 100, 25+(counter*20)); counter++; } g.setColor(Color.yellow); counter=0; do { // the condition for this loop is tested at the end of the loop // the loop will always run at least once g.drawString("Carman", 175, 25+(counter*20)); counter++; }while(counter < 5); } }