Class GPACalculator
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----java.applet.Applet
|
+----GPACalculator
-
public class GPACalculator
-
extends Applet

-
action(Event,
Object)
-
Performs appropriate action when button is clicked.
-
convert(String)
-
Calculates the numeric grade, given the letter grade.
-
init()
-
This function is called initially, when the program begins executing.

init
public void init()
-
This function is called initially, when the program begins executing. It
initializes the graphics window, and sets total_grade, total_credits, and
gpa to 0.
-
Overrides:
-
init in class Applet
convert
public int convert(String grade)
-
Calculates the numeric grade, given the letter grade.
-
Parameters:
-
grade - the letter grade
-
Returns:
-
the numeric grade or -1 if the input is invalid
action
public boolean action(Event event,
Object arg)
-
Performs appropriate action when button is clicked. If the submit button
is clicked, the current_grade is added to total_grade and current_credits
is added to total_credits, and gpa is recalculated, and these new values
are displayed on the screen. If the clear button is clicked, it sets total_credits
and gpa to 0 and writes this to the screen. If the grade_choice is clicked,
convert is called to convert to a number grade and stores it in current_grade.
Similarly, if credit_choice is clicked, the number of credits is stored
to current_credits.
-
Parameters:
-
event - the event that occurred
-
arg - contains information about the event
-
Returns:
-
true if event handled by the function
-
Overrides:
-
action
in class Component