Kamis, 08 Maret 2012

Menerima Inputan dari Keyboard menggunakan JOptionPane

Script :
import javax.swing.JOptionPane;

public class T3_JOptionPane {

public static void main(String[] args) {
int bil1, bil2, bil3, counter;
float average;
String input1 = JOptionPane.showInputDialog("Masukkan Bilangan ke-1 :");
bil1 = Integer.parseInt(input1);
String input2 = JOptionPane.showInputDialog("Masukkan Bilangan ke-2 :");
bil2 = Integer.parseInt(input2);
String input3 = JOptionPane.showInputDialog("Masukkan Bilangan ke-3 :");
bil3 = Integer.parseInt(input3);
counter = bil1 + bil2 + bil3;
average = counter / 3;
String msg = "Jumlah Bilangan : " + counter + "\n Rata -Rata Bilangan : " + average;
JOptionPane.showMessageDialog(null, msg);
}
}

Implementasi :




0 komentar:

Posting Komentar

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | GreenGeeks Review