Either, or both. This is a design decision.
Floating point would probably be best for a real application, but, to simplify things let us:
int
variable, fahrTemp
.int
variable celsTemp
.
This work will by done by a
FahrConvert
object.
Here is a sketch of the code:
public class FahrConvert . . . { int fahrTemp ; // input from the user: Fahrenheit temperature int celsTemp ; // result: Celsius temperature public FahrConvert() // constructor for FahrConvert { . . . . . } // The application public void convert( ) { celsTemp = ((fahrTemp-32) * 5) / 9; } public static void main ( String[] args ) { . . . . . } }
You could continue on from here and develop a non-GUI application
where the main()
method does input and output with the keyboard and monitor.
You might do this if you wanted to debug the
application code first before working on the GUI.
However, this example will do input and output with GUI components.
Now give some thought to the graphical interface.