A good answer might be:

Either, or both. This is a design decision.

Variables

To simplify things let us decide to:

  • Convert the input string to an int variable.
  • Evaluate the formula using integer arithmetic.
  • Save the result as an int.
All this work will be done with the methods and variables of an object. Call the class of the object  fahrConvert. With these decisions, the application code can be sketched out:

public class fahrConvert
{

  int fahrTemp ;          // input from the user: fahrenheit temperature
  int celsTemp ;          // result: celsius temperature
  
  fahrConvert()           // constructor for fahrConvert
  {  
    . . . . .
  }

  // The application
  public void convert( )  
  {
    celsTemp = ((fahrTemp-32) * 5) / 9;
  }

  . . . . .

  public static void main ( String[] args )
  {
    fahrConvert fahr  = new fahrConvert() ;
    
    . . . . .
  }
}

We could continue on from here and develop a non-GUI application where main() does input and output. You might do this if you wanted to debug the application code before working on the GUI. Now give some thought to the graphical interface.

QUESTION 3:

  • Into what type of GUI component will the user enter the fahrenheit temperature?
  • What type of GUI component will display the result?

Click Here after you have answered the question