Revision: 72409
Updated Code
at August 19, 2017 01:49 by WaleedAhsan123
Updated Code
/*
* Programmer: Waleed Ahsan
* This program is written by me and this code shall not be copied for any other program
*/
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class TemperatureConvertor {
public static void main(String args[])
{
JFrame answerbox = new JFrame();
String choice;
String DEGREE = "\u00b0";
double celsius;
double fahrenheit;
choice = JOptionPane.showInputDialog("Type 'A' if you want to convert Celsius to Fahrenheit\nType 'B' if you want to convert Fahrenheit to Celsius");
if(choice.equals("A") || (choice.equals("a")))
{
celsius = Double.parseDouble(JOptionPane.showInputDialog("What is the Celsius temperature you want to convert?"));
celsius = (celsius * 1.8) + 32;
JOptionPane.showMessageDialog(answerbox, "Your new temperature is " + celsius + DEGREE + "F");
}
if(choice.equals("B") || (choice.equals("b")))
{
fahrenheit = Double.parseDouble(JOptionPane.showInputDialog("What is the Fahrenheit temperature you want to convert?"));
fahrenheit = (fahrenheit - 32) * 5/9;
JOptionPane.showMessageDialog(answerbox, "Your new temperature is " + fahrenheit + DEGREE + "C");
}
}
}
Revision: 72408
Updated Code
at August 19, 2017 01:48 by WaleedAhsan123
Updated Code
/*
* Programmer: Waleed Ahsan
* This program is written by me and this code shall not be copied for any other program
*/
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class TemperatureConvertor {
public static void main(String args[])
{
JFrame answerbox = new JFrame();
String choice;
String DEGREE = "\u00b0";
double celsius;
double fahrenheit;
choice = JOptionPane.showInputDialog("Type 'A' if you want to convert Celsius to Fahrenheit\nType 'B' if you want to convert Fahrenheit to Celsius");
if(choice.equals("A") || (choice.equals("a")))
{
celsius = Double.parseDouble(JOptionPane.showInputDialog("What is the Celsius temperature you want to convert?"));
celsius = (celsius * 1.8) + 32;
JOptionPane.showMessageDialog(answerbox, "Your new temperature is " + celsius + DEGREE + "F");
}
if(choice.equals("B") || (choice.equals("b")))
{
farenheit = Double.parseDouble(JOptionPane.showInputDialog("What is the Farenheit temperature you want to convert?"));
farenheit = (farenheit - 32) * 5/9;
JOptionPane.showMessageDialog(answerbox, "Your new temperature is " + fahrenheit + DEGREE + "C");
}
}
}
Revision: 72407
Updated Code
at August 19, 2017 01:47 by WaleedAhsan123
Updated Code
/*
* Programmer: Waleed Ahsan
* This program is written by me and this code shall not be copied for any other program
*/
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class TemperatureConvertor {
public static void main(String args[])
{
JFrame answerbox = new JFrame();
String choice;
String DEGREE = "\u00b0";
double celsius;
double farenheit;
choice = JOptionPane.showInputDialog("Type 'A' if you want to convert Celsius to Fahrenheit\nType 'B' if you want to convert Fahrenheit to Celsius");
if(choice.equals("A") || (choice.equals("a")))
{
celsius = Double.parseDouble(JOptionPane.showInputDialog("What is the Celsius temperature you want to convert?"));
celsius = (celsius * 1.8) + 32;
JOptionPane.showMessageDialog(answerbox, "Your new temperature is " + celsius + DEGREE + "F");
}
if(choice.equals("B") || (choice.equals("b")))
{
farenheit = Double.parseDouble(JOptionPane.showInputDialog("What is the Farenheit temperature you want to convert?"));
farenheit = (farenheit - 32) * 5/9;
JOptionPane.showMessageDialog(answerbox, "Your new temperature is " + fahrenheit + DEGREE + "C");
}
}
}
Revision: 72406
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 19, 2017 01:44 by WaleedAhsan123
Initial Code
/*
* Programmer: Waleed Ahsan
* This program is written by me and this code shall not be copied for any other program
*/
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class TemperatureConvertor {
public static void main(String args[])
{
JFrame answerbox = new JFrame();
String choice;
String DEGREE = "\u00b0";
double celsius;
double farenheit;
choice = JOptionPane.showInputDialog("Type 'A' if you want to convert Celsius to Farenheit\nType 'B' if you want to convert Farenheit to Celsius");
if(choice.equals("A") || (choice.equals("a")))
{
celsius = Double.parseDouble(JOptionPane.showInputDialog("What is the Celsius temperature you want to convert?"));
celsius = (celsius * 1.8) + 32;
JOptionPane.showMessageDialog(answerbox, "Your new temperature is " + celsius + DEGREE + "F");
}
if(choice.equals("B") || (choice.equals("b")))
{
farenheit = Double.parseDouble(JOptionPane.showInputDialog("What is the Farenheit temperature you want to convert?"));
farenheit = (farenheit - 32) * 5/9;
JOptionPane.showMessageDialog(answerbox, "Your new temperature is " + farenheit + DEGREE + "C");
}
}
}
Initial URL
https://github.com/WaleedAhsan123
Initial Description
This is written in Java and the code has not been copied from the web
Initial Title
Temperature Convertor
Initial Tags
Initial Language
Java