CIS 120 INTRODUCTION TO PROGRAMMING I
LAB EXERCISE 8: METHODS IN JAVA CONTINUED
Write a Java program (as an applet) that enables the user to enter either a Fahrenheit
temperature and display the Celsius equivalent or enter a Celsius temperature and display
the Fahrenheit equivalent as many times as he chooses. No error checking required.
Your solution must include the following integer methods:
1. Method Celsius returns the Celsius equivalent of a Fahrenheit temperature using
c = 5.0/9.0 * (Fahrenheit – 32)
2. Method Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature:
f = 0.9/5.0 * Celsius + 32
The GUI for your applet should look like the attached illustration. You will need 2
JLabels, 2 JTextFields, and one JButton. The output JtextField should not be editable.
Use the Craps program (Figure 6.9 on pages 265 – 269 of your textbook) and the
ActionListener Demo program (program 4.7 on 4.28 and 4.29 of your green book) as
models. Some of the new topics in these programs will be covered in class and in lab.
Use the following code in your html file to properly size your GUI (IMPORTANT
NOTE: omit the angle brackets around the classname in line 2 of the html code
and substitute your own classname):
<applet code = "<classname>.class" width = "370" height = "100">
1. First 15-20 minutes of lab session—Develop two-level flowchart of
solution, using expansion boxes to illustrate method calls.
2. Have graduate assistant or supplemental instructor approve your
3. Code solution.
Note: You are not to begin coding until one of the proctors has initialed
1. Flow chart with graduate assistant’s initials showing approval
2. Source code and test results clearly demonstrating all branches of program works
as well as looping structure.