/ Published in: Java
This is written in Java and the code has not been copied from the web
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* * 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 { { String choice; 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; } 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; } } }
URL: https://github.com/WaleedAhsan123