IN JAVA…Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then see the equiva-lent Fahrenheit temperature. Use the following formula to make the conversion: F = (9/5)C + 32 F is the Fahrenheit temperature and C is the Celsius temperature. Instead of only converting from Celsius to Fahrenheit, also convert from Fahrenheit to Celsius depending on the user's choice. Some hints: Use JTextField and JLabel for required input. The KiloConverter program is a good example to get you started. Please make sure you comment your code thoroughly. The code should be nicely formatted and should use proper variables.
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.text.DecimalFormat;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class TempCalc {
static JLabel outText = new JLabel("");
static String input = "", output = "";
static JTextField inputText = new JTextField();
static DecimalFormat df = new
DecimalFormat(".##");
public TempCalc() {
JFrame f = new JFrame();
JLabel inputLabel = new
JLabel("Input");
JLabel outputLabel = new
JLabel("Outut");
inputLabel.setBounds(150, 70, 80, 30);
inputText.setBounds(190, 70,
300, 30);
outText.setBounds(190, 400, 300,
30);
outputLabel.setBounds(150, 400,
300, 30);
JLabel inputScale = new
JLabel("Input Scale");
inputScale.setBounds(75, 100, 300,
30);
ButtonGroup bg = new
ButtonGroup();
JRadioButton input1 = new
JRadioButton("Celcius");
JRadioButton input2 = new
JRadioButton("Farhenheit");
input1.setBounds(75, 140, 300,
30);
input2.setBounds(75, 180, 300,
30);
bg.add(input1);
bg.add(input2);
JLabel outputScale = new
JLabel("output Scale");
outputScale.setBounds(575, 100,
300, 30);
ButtonGroup bg1 = new
ButtonGroup();
JRadioButton output1 = new
JRadioButton("Celcius");
JRadioButton output2 = new
JRadioButton("Farhenheit");
output1.setBounds(575, 140, 300,
30);
output2.setBounds(575, 180, 300,
30);
bg1.add(output1);
bg1.add(output2);
input1.addItemListener(new
ItemListener() {
public void
itemStateChanged(ItemEvent e) {
System.out.println(e.getStateChange());
if (e.getStateChange() == 1) {
input = "C";
if (input.length() != 0
&& output.length() != 0) {
if
(output.equals("F")) {
outText.setText(
df.format(TemparatureCal.celciusToFahrenheit(inputText.getText().trim())));
}
if
(output.equals("K")) {
outText.setText(df.format(TemparatureCal.celciusToKelvin(inputText.getText().trim())));
}
if
(output.equals("C")) {
outText.setText(df.format(Double.parseDouble(inputText.getText().trim())));
}
} else {
outText.setText("No Input");
}
}
}
});
input2.addItemListener(new
ItemListener() {
public void
itemStateChanged(ItemEvent e) {
System.out.println(e.getStateChange());
if (e.getStateChange() == 1) {
input = "F";
if (input.length() != 0
&& output.length() != 0) {
if
(output.equals("F")) {
outText.setText((df.format(Double.parseDouble(inputText.getText().trim())))
+ "");
}
if
(output.equals("K")) {
outText.setText(
df.format(TemparatureCal.fahrenheitToKelvin(inputText.getText().trim()))
+ "");
}
if
(output.equals("C")) {
outText.setText(
df.format(TemparatureCal.fahrenheitTocelcius(inputText.getText().trim()))
+ "");
}
} else {
outText.setText("No Input");
}
}
}
});
output1.addItemListener(new
ItemListener() {
public void
itemStateChanged(ItemEvent e) {
System.out.println(e.getStateChange());
if (e.getStateChange() == 1) {
output = "C";
if (input.length() != 0
&& output.length() != 0) {
if
(input.equals("F")) {
outText.setText(
df.format(TemparatureCal.fahrenheitTocelcius(inputText.getText().trim())));
}
if
(input.equals("K")) {
outText.setText(df.format(TemparatureCal.kelvinToCelcius(inputText.getText().trim()))
+ "");
}
if
(input.equals("C")) {
outText.setText(df.format(Double.parseDouble(inputText.getText().trim())));
}
} else {
outText.setText("No Input");
}
}
}
});
output2.addItemListener(new
ItemListener() {
public void
itemStateChanged(ItemEvent e) {
if (e.getStateChange() == 1) {
output = "F";
if (input.length() != 0
&& output.length() != 0) {
if
(input.equals("F")) {
outText.setText(df.format(Double.parseDouble(inputText.getText().trim()))
+ "");
}
if
(input.equals("K")) {
outText.setText(
df.format(TemparatureCal.kelvinToFahrenheit(inputText.getText().trim()))
+ "");
}
if
(input.equals("C")) {
outText.setText(
df.format(TemparatureCal.celciusToFahrenheit(inputText.getText().trim()))
+ "");
}
} else {
outText.setText("No Input");
}
}
}
});
f.add(output1);
f.add(output2);
f.add(input1);
f.add(input2);
f.add(inputLabel);
f.add(inputText);
f.add(outText);
f.add(outputLabel);
f.setSize(1000, 600);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new TempCalc();
}
}
class TemparatureCal {
static public double celciusToFahrenheit(String input)
{
double temp =
Double.parseDouble(input);
temp = temp * 9 / 5 + 32;
return temp;
}
static public double celciusToKelvin(String input)
{
double temp =
Double.parseDouble(input);
temp = temp + 273.15;
return temp;
}
static public double fahrenheitTocelcius(String
input) {
double temp =
Double.parseDouble(input);
temp = (temp - 32) * 5 / 9;
return temp;
}
static public double fahrenheitToKelvin(String
input) {
double temp =
Double.parseDouble(input);
temp = (temp + 459.67) * 5 /
9;
return temp;
}
static public double kelvinToFahrenheit(String
input) {
double temp =
Double.parseDouble(input);
temp = temp * 9 / 5 - 459.67;
return temp;
}
static public double kelvinToCelcius(String input)
{
double temp =
Double.parseDouble(input);
temp = temp - 273.15;
return temp;
}
}
IN JAVA…Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be...
IN JAVA…PLEASE comment the code thoroughly so I can understand the thought process. Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then see the equivalent Fahrenheit temperature. Use the following formula to make the conversion: F = (9/5)C + 32 F is the Fahrenheit temperature and C is the Celsius temperature. Instead of only converting from Celsius to Fahrenheit, also convert from Fahrenheit...
(in python) Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user s... Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then see the equivalent Fahrenheit temperature. Use the following formula to make the conversion ( F=9/5 C + 32) where F is the Fahrenheit temperature and C is the Celsius temperature
Question: Fahrenheit To Celsius Temperature Converter GUI Assignment Write A GUI To... java Fahrenholt to Celsius Temperature Converter GUI Assignment Write a Gul to convert Fahrenheit temperatures to Celsius temperatures and has the following appearance: Com Convert It must include the following foatures • The frame we must say 'Fahrenheit to Celsius Temperature Converter • A border layout will be used for the GUI • The JLabelite of the GUI wil suy Fahrerholt to Celsius Temperature Converter and be in...
In Python, write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is as follows: F=(9/5)C+32 The program should ask the user to enter a temperature in Celsius, then display the temperature converted to Fahrenheit.
Write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is as follows: F=95C+32 The program should ask the user to enter a temperature in Celsius, and then display the temperature converted to Fahrenheit. I'm doing this on Python.
For this assignment you will create a program converting Fahrenheit temperatures to Celsius temperatures. The formula for converting a temperature from Celsius to Fahrenheit is: F = C x 1.8 + 32, where F is the Fahrenheit temperature and C is the Celsius temperature. Write a function named Fahrenheit that accepts a Celsius temperature as an argument and returns the temperature converted to Fahrenheit. Demonstrate the function by accepting a Celsius temperature from a user and displaying the temperature converted...
Write a program that inputs Celsius temperatures (use a void function), converts them to Fahrenheit (f = 9/5C + 32, use a value returning function) and prints whether it is a day for swimming or skiing (use a function). Include a loop in main that quits looping on -999. code in C++ please include a screen shot of the code as it is easier to read
Write a Java program that converts Centigrade temperatures to Fahrenheit temperatures. The formula is F = 9/5C + 32 F is the Fahrenheit temperature and C is the centigrade temperature.
Java program
Write a Temperature class that represents temperatures in degrees in both Celsius and Fahrenheit. Use a floating- point number for the temperature and a character for the scale, eitherでfor Celsius or 'F' for fahrenheit. The class should have Four constructors: one for the number of degrees, one for the scale, one for both the degrees and scale, and a default constructor. For each of these constructors, assume zero degrees if no value is specified and celsius if no...
Write a Python application that allows the user to convert between temperatures in Fahrenheit and temperatures in Celsius. Below are the formulas for both, where Tc is temperature in Celsius and Tf is temperature in Fahrenheit: There should be 3 separate py files/classes- the Model, the View, and the Controllers. The Model contains the F/C conversion. The View is the frame. The controller runs the program and communicates between the Controller and Model