//////////////////////////////////// // Your name. // Your lab section. // Today's date. //////////////////////////////////// // Program to add times import awb.*; import java.awt.*; import java.awt.event.*; public class AddTimeDebug extends java.applet.Applet implements ActionListener { // min1 and min2 are integers between 0 and 59, inclusive int min1, min2; // sec1 and sec2 are integers between 0 and 59, inclusive int sec1, sec2; // the sum of the times is given in hours, minutes and seconds int secSum, minSum, hrSum; IntField tMin1, tSec1, tMin2, tSec2; TextField tm1, ts1, tm2, ts2, tResult; Button bCompute; public void init() { tMin1 = new IntField(10); tSec1 = new IntField(10); tMin2 = new IntField(10); tSec2 = new IntField(10); tm1 = new TextField("Enter the minutes for Time 1:"); ts1 = new TextField("Enter the seconds for Time 1:"); tm2 = new TextField("Enter the minutes for Time 2:"); ts2 = new TextField("Enter the seconds for Time 2:"); tResult = new TextField(60); bCompute = new Button("Compute"); bCompute.addActionListener(this); add(tm1); add(tMin1); add(ts1); add(tSec1); add(tm2); add(tMin2); add(ts2); add(tSec2); add(bCompute); add(tResult); } public void actionPerformed(ActionEvent event) { Object cause = event.getSource(); if (cause == bCompute) { min1 = tMin1.getInt(); sec1 = tSec1.getInt(); min2 = tMin2.getInt(); sec2 = tSec2.getInt(); secSum = sec1 + sec2 % 60; minSum = ((min1 + min2) + ((sec1 + sec2) / 60) % 60; hrSum = ((min1 + min2) + ((sec1 + sec2) / 60)) / 60; tResult.setText("The sum of the times is: " + hrSum + ":" + minSum + ":" + secSum); } } }