Koding Java untuk suhu


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package javaapplication2;

/**
*
* @author COMPAQ
*/
import javax.swing.JOptionPane;

public class Main {

public static void main(String args[])
{
int celcius;
String str=JOptionPane.showInputDialog (“\nMasukkan bilangan yang akan dikonversi (Celcius)= “);

celcius = Integer.parseInt(str);

System.out.println(“Nilainya dalam fahrenheit : ” +(Convert(celcius)));
System.out.println(“Nilainya dalam Reamur : ” +(Konversi(celcius)));
}

public static double Convert(int celcius)
{
double fahrenheit;
fahrenheit = ( celcius*9/5 ) + 32;

return fahrenheit;
}

public static double Konversi(int celcius)
{
double reamur;
reamur = ( celcius*4/5 );

return reamur;
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s