Thursday, March 08, 2007

Java Programming... Ilmu yg agak lama ditinggalkan...

import java.text.*;
import javax.swing.JOptionPane;

public class kiloToMilesUsingInputDialogWithLoop {
public static void main (String[] args) {

double km = 0.000, miles = 0.000;
int ctrl;
DecimalFormat p = new DecimalFormat("0.000");
//prompt the user to input using input Dialog box

do {

km = Double.parseDouble(JOptionPane.showInputDialog(null,"Masukkan berapa km:","INPUT BERAPA KM",JOptionPane.QUESTION_MESSAGE));

miles = km*0.621;

//paparkan ke dalam kekotak pada skrin

JOptionPane.showMessageDialog(null,p.format(km)+ "km bersamaan dengan " + p.format(miles)+ " batu.\n","KEPUTUSAN KM ke miles",JOptionPane.INFORMATION_MESSAGE);

ctrl = Integer.parseInt(JOptionPane.showInputDialog(null,"Taip 1 utk tamatkan program. Taip selain 1 utk teruskan program : ","TERUSKAN PROGRAM?",JOptionPane.QUESTION_MESSAGE));

}
while (ctrl !=1);

System.exit(0);

}

}

No comments: