// SumOfCodes.java // Illustrates processing using the for loop // Java 1.0 event handling. import java.awt.*; import java.applet.*; public class SumOfCodes extends Applet { TextField myTF = new TextField(); public void init() { setLayout(new BorderLayout()); add("North", myTF); } public boolean action(Event e, Object o) { String s = myTF.getText(); int nChars = s.length(); int sumOfCodes = 0; for (int counter = 0; counter < nChars; ++counter) { sumOfCodes += s.charAt(counter); } myTF.setText( "Your name is worth " + sumOfCodes + " Unicode points"); return true; } }