CONTOH PROGRAM KONVERSI DALAM BAHASA JAVA
1.
ANGKA
DALAM CM DAN INCI
PROGRAMNYA
:
import
java.util.Scanner;
public
class Konversi_cm_ke_inci
{
public
static void main (String args[])
{Scanner
masuk = new Scanner (System.in);
float
m,cm,inci;
System.out.println("Masukkan
ukuran dalam meter:");
m=masuk.nextFloat();
cm
=m*100;
inci=m*100/2.54f;
System.out.println("Ukuran
dalam CM : "+cm);
System.out.println("Ukuran
dalam Inci : "+inci);
}
}
HASIL
OUTPUT :
2.
KONVERSI
SUHU
PROGRAMNYA
:
import java.util.Scanner;
public class KonversiSuhu
{
public static void main (String args[])
{
Scanner masuk = new Scanner (System.in);
int celcius;
float fahreinhet,reamur,kelvin;
System.out.println("Masukkan derejat
celcius:");
celcius=masuk.nextInt();
fahreinhet=9f/5f*celcius+32f;
reamur=4f/5f*celcius;
kelvin=celcius+273;
System.out.println("fahreinhet :
"+fahreinhet);
System.out.println("reamur :
"+reamur);
System.out.println("kelvin :
"+kelvin);
}
}
HASIL
OUTPUT :
Tidak ada komentar:
Posting Komentar