Professional Documents
Culture Documents
1
1
konversisuhu;
import java.util.Scanner;
public class konversisuhu {
while(valid!=true)
{
System.out.println("Konversi Suhu");
System.out.print("Masukkan Suhu [C/F/R/K] (misal: 100 R)= ");
suhu = input.nextDouble();
awal = input.next().charAt(0);
switch(awal){
case 'C':
Reamur = fromcelcius.toreamur();
Fahrenheit = fromcelcius.tofahrenheit();
Kelvin = fromcelcius.tokelvin();
System.out.println("Suhu = "+suhu+" Celcius");
System.out.println("Fahrenheit = "+Fahrenheit);
System.out.println("Kelvin = "+Kelvin);
System.out.println("Reamur = "+Reamur);
valid=true;
break;
case 'F':
Celcius = fromfahrenheit.tocelcius();
Reamur = fromfahrenheit.toreamur();
Kelvin = fromfahrenheit.tokelvin();
System.out.println("Suhu ="+suhu+" Fahrenheit");
System.out.println("Celcius = "+Celcius);
System.out.println("Kelvin = "+Kelvin);
System.out.println("Reamur = "+Reamur);
valid=true;
break;
case 'K':
Celcius = fromkelvin.tocelcius();
Reamur = fromkelvin.toreamur();
Fahrenheit = fromkelvin.tofahrenheit();
System.out.println("Suhu ="+suhu+" Kelvin");
System.out.println("Celcius = "+Celcius);
System.out.println("Fahrenheit = "+Fahrenheit);
System.out.println("Reamur = "+Reamur);
valid=true;
break;
case 'R':
Celcius = fromreamur.tocelcius();
Fahrenheit = fromreamur.tofahrenheit();
Kelvin = fromreamur.tokelvin();
System.out.println("Suhu ="+suhu+" Reamur");
System.out.println("Celcius = "+Celcius);
System.out.println("Fahrenheit = "+Fahrenheit);
System.out.println("Kelvin = "+Kelvin);
valid=true;
break;
default :
System.out.println("Masukkan Suhu Dengan Benar [C,F,K,R]");
}
}
}
}
package com.konversisuhu;