Kamis, 08 Maret 2012

JOptionPane-Array

Script :
import javax.swing.JOptionPane;

public class JO_Array {

public static void main(String[] args) {
String input = JOptionPane.showInputDialog("Input angka :");
int masuk = Integer.parseInt(input);
int counter = 0;
for (int i = 1; i <= masuk; i++) { String bil = JOptionPane.showInputDialog("Masukkan angka ke-" + i); int angka = Integer.parseInt(bil); counter += angka; } String msg = ("Total angka adalah :\n" + counter); 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