JAVA CODE
//Test4 program import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Test4 extends Applet implements AdjustmentListener { Label Slider1Lbl, Slider2Lbl; Scrollbar Slider1, Slider2; int Num1, Num2; public void init() { Slider1Lbl = new Label (" Enter shallow end : " ); add(Slider1Lbl); Slider1 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 11); Slider1.addAdjustmentListener (this); add(Slider1); Slider2Lbl = new Label (" Enter Deep end : " ); add(Slider2Lbl); Slider2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 31 ); Slider2.addAdjustmentListener (this); add(Slider2); } public void paint( Graphics g ) { int sum = (Num1+Num2)*20*5/20; g.drawString("The shallow end is : " +(float)Num1/10, 50, 100); g.drawString("The deep end is : " + (float)Num2/10, 50, 120); g.drawString("The volume is " + sum, 50, 140 ); g.drawLine(50, 160, 250, 160); g.drawLine(50, 160, 50, 160+Num2); g.drawLine(250, 160, 250, 160+Num1); g.drawLine(50, 160+Num2, 250, 160+Num1); } public void adjustmentValueChanged( AdjustmentEvent e ) { if (e.getSource() == Slider1) Num1 = e.getValue(); else Num2 = e.getValue(); repaint(); } }