CST2641 Advanced Java I
Lab Week 1


Exercises

Exercise 3.1 Vol I

Using float types, set up a variable containing a Fahrenheit temperature, then display the Celsius (centigrade) equivalent.  The formula is:
c = (f - 32.0f) * 5.0f / 9.0f

The resulting class file should be an application, NOT an applet.  Inputs should be entered through a dialog box.  Output results are printed directly to the console.  Input and output should be of precision 2.

Ex3_1.class

 

Exercise 3.2 Vol I

Do the same exercise as above, but without the use of the input dialog box.  Instead use input arguments.

Ex3_2.class

Exercise 4.1 Vol I

In chapter 7 of Java for Students, there is a dice throwing program.  Convert the applet to a stand alone program.  Chapter 18 in Java for Students describes how to do the conversion from applets to stand alone programs.  Use two text fields with appropriate labels to display the dice digits.  Also make a separate Die.class that simulates the roll of the die.  Each dice should be an object of the class Die.

Here is the original program which is an applet that will run in a browser:
Ex4_1a.java
See the program run in a browser.

Here is the finished result.  This is a standalone program (cannot be run in a browser).
DiceRoll.class
Die.class