JAVA CODE

//Ex3_4 program
import java.applet.Applet;
import java.awt.*;

public class Ex3_4 extends Applet
{
   private int rainfall[] = { 150, 175, 120 };
   private int year[] = { 1994, 1995, 1996 };
   private Color c[] = { Color.green, Color.yellow, Color.blue };

   public void paint (Graphics g)
   {
      for (int i = 0; i < rainfall.length; i++)
      {
         g.setColor (Color.red);
         g.drawLine (90, 30+30*i, rainfall[i], 30+30*i);
         g.setColor (Color.black);
         g.drawString (year[i] + "  " + rainfall[i] + " cm", 10, 30+30*i);
      }

      for (int i = 0; i < rainfall.length; i++)
      {
         g.setColor (c[i]);
         g.fillRect (90, 140+30*i, rainfall[i], 10);
         g.setColor (Color.black);
         g.drawString (year[i] + "  " + rainfall[i] + " cm", 10, 150+30*i);
      }
   }
}