Thursday, August 11, 2022

Celsius To Fahrenheit Using JOptionPane in Java

 Machine Problem

Write a program that asks for a temperature in Celsius and prints out the temperature

in Fahrenheit. Use InputBox for input and OutputBox for output. The formula to

convert Celsius to the equivalent Fahrenheit is  fahrenheit = 1.8 x celsius + 32

 I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

=================================================


Want to support my channel?

GCash Account

Jake Pomperada


09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada

Thank you very much for your support.






Program Listing

/* Write a program that asks for a temperature in Celsius and prints out the temperature
in Fahrenheit. Use InputBox for input and OutputBox for output. The formula to
convert Celsius to the equivalent Fahrenheit is:
*
fahrenheit = 1.8 x celsius + 32
 * 
 */
package demo;


import javax.swing.JOptionPane;
import java.text.DecimalFormat;

public class Temperature {

private static final DecimalFormat df = new DecimalFormat("0.00");
 
public static void main(String[] args) {
// TODO Auto-generated method stub
  String celsius = 

         JOptionPane.showInputDialog( "Enter Temperature in Celsius : " );
       double celsius_temp = Double.parseDouble(celsius); 
      
      double Fahrenheit = (1.8 * celsius_temp) + 32; 
      
      JOptionPane.showMessageDialog( null,  "The temperature in Fahrenheit :  " + df.format(Fahrenheit) 
        , "The Result", JOptionPane.INFORMATION_MESSAGE );
}

}


No comments:

Post a Comment