document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /**
  2.  *
  3.  * @author Agus
  4.  */
  5. import java.util.*;
  6. public class KonversiSuhu {
  7.    
  8.     static double SuhuAwal;
  9.     static char Awal;
  10.     /**
  11.      * @param args the command line arguments
  12.      */
  13.     public static void main(String[] args) {
  14.         // TODO code application logic here
  15.         Celcius fromCelcius = new Celcius();
  16.         Fahrenheit fromFahrenheit = new Fahrenheit();
  17.         Reamur fromReamur = new Reamur();
  18.         Kelvin fromKelvin = new Kelvin();
  19.        
  20.         double Fahrenheit, Kelvin,Celcius,Reamur;
  21.         boolean valid=false;
  22.         Scanner input = new Scanner(System.in);
  23.        
  24.         while(valid!=true)
  25.         {
  26.             System.out.println("Program Konversi Suhu");
  27.             System.out.print("Masukkan suhu awal dan nilainya (D/F/R/K) (misal : 100 C):");
  28.             SuhuAwal=input.nextDouble();
  29.             Awal = input.next().charAt(0);
  30.  
  31.             switch(Awal){
  32.                 case \'C\':
  33.                     Reamur = fromCelcius.toReamur();
  34.                     Fahrenheit = fromCelcius.toFahrenheit();
  35.                     Kelvin = fromCelcius.toKelvin();
  36.                     System.out.println("Suhu awal ="+SuhuAwal+" Celcius\\nHasil:");
  37.                     System.out.println("Fahrenheit : "+Fahrenheit);
  38.                     System.out.println("Kelvin : "+Kelvin);
  39.                     System.out.println("Reamur : "+Reamur);
  40.                     valid=true;
  41.                     break;
  42.                 case \'F\':
  43.                     Celcius = fromFahrenheit.toCelcius();
  44.                     Reamur = fromFahrenheit.toReamur();
  45.                     Kelvin = fromFahrenheit.toKelvin();
  46.                     System.out.println("Suhu awal ="+SuhuAwal+" Fahrenheit\\nHasil:");
  47.                     System.out.println("Celcius : "+Celcius);
  48.                     System.out.println("Kelvin : "+Kelvin);
  49.                     System.out.println("Reamur : "+Reamur);
  50.                     valid=true;
  51.                     break;
  52.                 case \'K\':
  53.                     Celcius = fromKelvin.toCelcius();
  54.                     Reamur = fromKelvin.toReamur();
  55.                     Fahrenheit = fromKelvin.toFahrenheit();
  56.                     System.out.println("Suhu awal ="+SuhuAwal+" Kelvin\\nHasil:");
  57.                     System.out.println("Celcius : "+Celcius);
  58.                     System.out.println("Fahrenheit : "+Fahrenheit);
  59.                     System.out.println("Reamur : "+Reamur);
  60.                     valid=true;
  61.                     break;
  62.                 case \'R\':
  63.                     Celcius = fromReamur.toCelcius();
  64.                     Fahrenheit = fromReamur.toFahrenheit();
  65.                     Kelvin = fromReamur.toKelvin();
  66.                     System.out.println("Suhu awal ="+SuhuAwal+" Reamur\\nHasil:");
  67.                     System.out.println("Celcius : "+Celcius);
  68.                     System.out.println("Fahrenheit : "+Fahrenheit);
  69.                     System.out.println("Kelvin : "+Kelvin);
  70.                     valid=true;
  71.                     break;
  72.                 default :
  73.                     System.out.println("Masukkan suhu secara benar [C,F,K,R]");
  74.             }
  75.         }
  76.     }
  77. }
');