Salju

Rabu, 27 November 2013

Script Program Konversi Suhu

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")) );

}

}



 
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGq3SnQmNDuxIvKA13kjh8cSlKIFjpjRo3IZyXKAsVNXr3yW9aqkmVpWLVOqdR7KDrOshAJlQ3v9MR0VVQ9R5ZzrSgrs24LLz_99Xk5uLnJfZvaGEP6TvhIvnaN95gf85c0X14MGW-goc/s320/suhu.jpg


Tidak ada komentar:

Posting Komentar