import java.util.*;
class
suhu
{
public static void main(String[] args)
{
int nilai,pilih;
double hasil;
String jawab;
System.out.println("Program Konversi SUHU
\n ");
jawab = "Y";
do
{
System.out.print("\n Pilihan \n");
System.out.print("\n1. Celcius -
Kelvin\n");
System.out.print("\n2. Celcius -
Fahrenheit\n");
System.out.print("\n3. Kelvin -
Celcius\n");
System.out.print("\n4. Fahrenheit -
Celcius\n");
System.out.print("\n Masukkan
Pilihan:");
pilih=new Scanner(System.in).nextInt();
if(pilih==1)
{
System.out.println("Masukkan Nilai
(Celcius):");
nilai = new Scanner(System.in).nextInt();
hasil=nilai + 273.15;
System.out.print("\n Suhu "+ nilai +
" Celcius =" + hasil + " Kelvin ");
}
else
if(pilih==2)
{
System.out.println("Masukkan Nilai
(Celcius):");
nilai = new Scanner(System.in).nextInt();
hasil=(9/5*nilai)+32;
System.out.print("\n Suhu "+ nilai +
" Celcius =" + hasil + " Fahrenheit ");
}
else
if(pilih==3)
{
System.out.println("Masukkan Nilai
(Kelvin):");
nilai = new Scanner(System.in).nextInt();
hasil=nilai - 273.15;
System.out.print("\n Suhu "+ nilai +
" Kelvin =" + hasil + " Celcius ");
}
else
{
System.out.println("Masukkan Nilai
(Fahrenheit):");
nilai = new Scanner(System.in).nextInt();
hasil=(nilai - 32) / 1.8;
System.out.print("\n Suhu "+ nilai +
" Fahrenheit =" + hasil + " Celcius ");
}
System.out.println("\n \n Apakah Anda
Ingin Mengulang:");
jawab=new Scanner(System.in).nextLine();
}while((jawab.equals("Y"))||(jawab.equals("y"))
);
}
}
Tidak ada komentar:
Posting Komentar