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

Why isn\'t continuing? and why isn\'t celsius working import javax.swing.JOption

ID: 665107 • Letter: W

Question

Why isn't continuing? and why isn't celsius working

import javax.swing.JOptionPane;
import java.util.Scanner;
public class lab_Exercise2_3
{
   public static void main(String[] args)
   {
       Scanner input = new Scanner(System.in);
       double C = 0;
       double F = 0;
       String strDegrees=JOptionPane.showInputDialog("Enter 1 to convert Celsius tp Fahrenheit and 2 to convert Farhrenheit to Celsiu");
       int degrees = Integer.parseInt(strDegrees);
      
       switch(degrees)
       {
       case 1:
           JOptionPane.showInputDialog("Enter the Celcius");
           F= (9.0/5.0*(C+32));
           JOptionPane.showMessageDialog(null,"The Fahrenheit is "+F);
       break;
       case 2:
           JOptionPane.showInputDialog("Enter Fahrenheit");
           C=(5.0/9*(F-32));
           JOptionPane.showMessageDialog(null,"The Celcius is "+C);
          
      
       String message= "Do you want to continue?";
       String title = "Press yes to continue or no to stop";
       int reply = JOptionPane.showConfirmDialog(null, message,title,JOptionPane.YES_NO_OPTION);
        if (reply==JOptionPane.YES_OPTION)
        {
            System.exit(0);
          }
       }
   }
}

Explanation / Answer

import javax.swing.JOptionPane; public class CelciusToFahrenheit { public static void main(String[] arg){ String CelciusString = JOptionPane.showInputDialog("Enter the Celcius: "); Double Celcius = Double.parseDouble(CelciusString); Double Fahrenheit = (9.0 / 5) * Celcius + 32; String output = "Fahrenheit is " + Fahrenheit; JOptionPane.showMessageDialog(null,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