import java.awt.*; import java.awt.event.*; import java.lang.*; import java.lang.Math; public class Prob2g extends java.applet.Applet { CheckboxGroup cbg; Checkbox Box0, Box1, Box2, Box3, Box4; Button Check; Label Response; public void init() { setBackground(Color.lightGray); setLayout(new FlowLayout(FlowLayout.LEFT)); cbg = new CheckboxGroup(); Box0 = new Checkbox("28.1 degrees", cbg, true); add(Box0); Box1 = new Checkbox("31.6 degrees", cbg, false); add(Box1); Box2 = new Checkbox("50.0 degrees", cbg, false); add(Box2); Box3 = new Checkbox("61.9 degrees", cbg, false); add(Box3); Box4 = new Checkbox("all the light is totally reflected internally", cbg, false); add(Box4); // Check button Check = new Button("Check Answer"); add(Check); Response = new Label("Choose the answer you think is correct", Label.CENTER); add(Response); } public boolean action (Event evt, Object arg) { if (evt.target instanceof Button) { if (cbg.getCurrent().equals(Box0)) { Response.setText("Right again!"); } else { Response.setText("Sorry...that's incorrect."); } } else return super.action(evt, arg); return true; } }