Advertisement
Wan_ich1

konversi suhu

Oct 10th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package konv.suhu;
  7.  
  8. import java.util.Scanner;
  9. class hitungsuhu
  10. {
  11.     float celkerea (float a)
  12.     {
  13.         return a*4/5;
  14.     }
  15.     float fahkera (float a)
  16.     {
  17.         return (a-32)*4/9;
  18.     }
  19.            
  20. }
  21. /**
  22.  *
  23.  * @author lenovo
  24.  */
  25. public class KonvSuhu {
  26.  
  27.     /**
  28.      * @param args the command line arguments
  29.      */
  30.     public static void main(String[] args) {
  31.         int pil;
  32.         Scanner input = new Scanner(System.in);
  33.         hitungsuhu s;
  34.         s=new hitungsuhu();
  35.        
  36.         do {
  37.         System.out.println("Pilihan : ");
  38.         System.out.println("1. celcius ke reamur \n2. fahrenheit ke reamur");
  39.         System.out.println("masukkan pilihan = ");
  40.         pil = input.nextInt();
  41.        
  42.         switch(pil){
  43.             case 1: System.out.println("input celcius = ");
  44.                     float a = input.nextFloat();
  45.                     System.out.println(a + " celcius = " +s.celkerea(a) + " reamur");
  46.                     break;
  47.             case 2: System.out.println("input fahrenheit = ");
  48.                     float b= input.nextFloat();
  49.                     System.out.println(b + " fahrenheat = " +s.fahkera(b) + " reamur");
  50.         }
  51.         }while(pil<=2);
  52.     }  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement