SHARE
TWEET

Untitled

a guest Jun 15th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package pertemuan10;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Pertemuan10 {
  6.  
  7.     public static void main(String[] args) {
  8.         double suhu, konversi;
  9.         byte pilihSatuan, pilihKonversi;
  10.        
  11.         Scanner input = new Scanner(System.in);
  12.         Konversi_suhu ks = new Konversi_suhu();
  13.        
  14.         konversi = 0;
  15.         System.out.println("=== Pilih satuan suhu ===");
  16.         System.out.println("1. Celcius");
  17.         System.out.println("2. Kelvin");
  18.         System.out.println("3. Reamur");
  19.         System.out.println("4. Fahrenheit");
  20.         System.out.print("Masukkan pilihan : ");
  21.         pilihSatuan = input.nextByte();
  22.  
  23.         System.out.print("Masukkan suhu : ");
  24.         suhu = input.nextDouble();
  25.  
  26.         System.out.println("=== Pilih konversi ===");
  27.         System.out.println("1. Celcius");
  28.         System.out.println("2. Kelvin");
  29.         System.out.println("3. Reamur");
  30.         System.out.println("4. Fahrenheit");
  31.         System.out.print("Masukkan pilihan : ");
  32.         pilihKonversi = input.nextByte();
  33.  
  34.         if (pilihSatuan == 1 && pilihKonversi == 1) {
  35.             konversi = suhu;
  36.         } else if (pilihSatuan == 1 && pilihKonversi == 2) {
  37.             konversi = ks.celciusToKelvin(suhu);
  38.         } else if (pilihSatuan == 1 && pilihKonversi == 3) {
  39.             konversi = ks.celciusToReamur(suhu);
  40.         } else if (pilihSatuan == 1 && pilihKonversi == 4) {
  41.             konversi = ks.celciusToFahrenheit(suhu);
  42.         } else if (pilihSatuan == 2 && pilihKonversi == 1) {
  43.             konversi = ks.kelvinToCelcius(suhu);
  44.         } else if (pilihSatuan == 2 && pilihKonversi == 2) {
  45.             konversi = suhu;
  46.         } else if (pilihSatuan == 2 && pilihKonversi == 3) {
  47.             konversi = ks.celciusToReamur(ks.kelvinToCelcius(suhu));
  48.         } else if (pilihSatuan == 2 && pilihKonversi == 4) {
  49.             konversi = ks.celciusToFahrenheit(ks.kelvinToCelcius(suhu));
  50.         } else if (pilihSatuan == 3 && pilihKonversi == 1) {
  51.             konversi = ks.reamurToCelcius(suhu);
  52.         } else if (pilihSatuan == 3 && pilihKonversi == 2) {
  53.             konversi = ks.celciusToKelvin(ks.reamurToCelcius(suhu));
  54.         } else if (pilihSatuan == 3 && pilihKonversi == 3) {
  55.             konversi = suhu;
  56.         } else if (pilihSatuan == 3 && pilihKonversi == 4) {
  57.             konversi = ks.celciusToFahrenheit(ks.reamurToCelcius(suhu));
  58.         } else if (pilihSatuan == 4 && pilihKonversi == 1) {
  59.             konversi = ks.fahrenheitToCelcius(suhu);
  60.         } else if (pilihSatuan == 4 && pilihKonversi == 2) {
  61.             konversi = ks.celciusToKelvin(ks.fahrenheitToCelcius(suhu));
  62.         } else if (pilihSatuan == 4 && pilihKonversi == 3) {
  63.             konversi = ks.celciusToReamur(ks.fahrenheitToCelcius(suhu));
  64.         } else if (pilihSatuan == 4 && pilihKonversi == 4) {
  65.             konversi = suhu;
  66.         }
  67.  
  68.         System.out.println("Hasil konversi : " + String.valueOf(konversi));
  69.         System.out.println();
  70.  
  71.         System.out.print("Apakah Anda ingin keluar? ");
  72.         System.out.println("0. Ya");
  73.         System.out.println("1. Tidak");
  74.     }
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top