Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using a Java Program. Write a program that will display a temperature conversion

ID: 3672125 • Letter: U

Question

Using a Java Program.

Write a program that will display a temperature conversion table. The user will input the beginning Fahrenheit temperature, the ending Fahrenheit temperature, and the temperature increment for display in the table. The program should then convert and display the temperature results in the form “Fahrenheit to
Celsius”. The formula for the conversion is as follows:

Celsius = ( 5 / 9 ) * ( Fahrenheit – 32 )

Your program should make use of the JOptionPane class. Use the same class for BOTH input and output.

Explanation / Answer

Program:

import javax.swing.JOptionPane;
import javax.swing.JTextArea;
public class TemperatureConversionTable {

   public static void main(String[] args) {
       // TODO Auto-generated method stub
       String fahrenheitStringStart,fahrenheitStringEnd;
       int fahrenheitStart,fahrenheitEnd;
      
       String CelsiusString="";
      
       fahrenheitStringStart =JOptionPane.showInputDialog("Enter starting fahrenheit temperature:");
       fahrenheitStart = Integer.parseInt(fahrenheitStringStart);
       fahrenheitStringEnd =JOptionPane.showInputDialog("Enter ending fahrenheit temperature:");
       fahrenheitEnd = Integer.parseInt(fahrenheitStringEnd);
       double Celsius=0;
       while(fahrenheitStart<=fahrenheitEnd)
       {
          
           Celsius = (5.0 / 9.0) * (fahrenheitStart-32.0);
           fahrenheitStart++;
          
       CelsiusString =Double.toString(Celsius);
       JTextArea jt=new JTextArea(CelsiusString);
        jt.setEditable(false);
        jt.setOpaque(false);
        jt.setTabSize(3);
        JOptionPane.showMessageDialog(null, jt);
       }
   }
}

Sample output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote