import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Suhu
{
public static void main(String[] args)
{
int menu;
do{
double kelvin, celsius;
String input = JOptionPane.showInputDialog("TEMPERATURE CONVERSION\n-----------------------------------------\n MENU :\n1. Dari Fahrenheit ke Kelvin\n2. Dari Fahrenheit ke Celsius\n3. Exit\nMasukan pilihan Conversion :");
menu = Integer.parseInt(input);
switch(menu)
{
case 1:{String inputString = JOptionPane.showInputDialog("Conversion \n\tDari Fahrenheit ke Kelvin\n Input Suhu :");
int fahrenheit = Integer.parseInt(inputString);
kelvin=(fahrenheit+459.67)/1.8;
JOptionPane.showMessageDialog(null,+ kelvin+ " Kelvin");
}break;
case 2:{String inputString = JOptionPane.showInputDialog("Conversion \n\tDari Fahrenheit ke Celsius\n Input Suhu :");
int fahrenheit = Integer.parseInt(inputString);
celsius=(fahrenheit-32)/1.8;
JOptionPane.showMessageDialog(null,+ celsius +" Celsius");
}break;
default:JOptionPane.showMessageDialog(null,"Input Not Faund");break;
}
}while(menu!=3);JOptionPane.showMessageDialog(null,"Terimakasih");
}
}
//use " Suhu" for file name.
examples of program run :
Input Menu:
import java.awt.*;
import java.awt.event.*;
class Suhu
{
public static void main(String[] args)
{
int menu;
do{
double kelvin, celsius;
String input = JOptionPane.showInputDialog("TEMPERATURE CONVERSION\n-----------------------------------------\n MENU :\n1. Dari Fahrenheit ke Kelvin\n2. Dari Fahrenheit ke Celsius\n3. Exit\nMasukan pilihan Conversion :");
menu = Integer.parseInt(input);
switch(menu)
{
case 1:{String inputString = JOptionPane.showInputDialog("Conversion \n\tDari Fahrenheit ke Kelvin\n Input Suhu :");
int fahrenheit = Integer.parseInt(inputString);
kelvin=(fahrenheit+459.67)/1.8;
JOptionPane.showMessageDialog(null,+ kelvin+ " Kelvin");
}break;
case 2:{String inputString = JOptionPane.showInputDialog("Conversion \n\tDari Fahrenheit ke Celsius\n Input Suhu :");
int fahrenheit = Integer.parseInt(inputString);
celsius=(fahrenheit-32)/1.8;
JOptionPane.showMessageDialog(null,+ celsius +" Celsius");
}break;
default:JOptionPane.showMessageDialog(null,"Input Not Faund");break;
}
}while(menu!=3);JOptionPane.showMessageDialog(null,"Terimakasih");
}
}
//use " Suhu" for file name.
examples of program run :
Input Menu:
Input Value:
OutPut: