listing program java

import javax.swing.*;
public class menu{
public static void main(String[]args){
String Pil = JOptionPane.showInputDialog (“1. Biodata \n 2.Genap \n 3.Pengulangan”);
int x = Integer.parseInt (Pil);
switch (x){
case 1:
String nama = JOptionPane.showInputDialog (“nama anda”);
String npm = JOptionPane.showInputDialog (“npm anda”);
JOptionPane.showMessageDialog (null,”nama anda : “+nama+”\n npm anda : “+npm);
break;
case 2:
String str = JOptionPane.showInputDialog (“masukan nilai = “);
int y = Integer.parseInt (str);
String a=””;
for (int i=1 ; i<=y ; i++){
if (i%2==0){
a=a + " "+Integer.toString(i);
}
}
JOptionPane.ShowInputDialog (null,a);
break;
case 3:
String kar = " ";
int nilai = Integer.parseInt (JOptionPane.showInputDialog ("masukan nilai = "));
for (int i=1 ; i<=nilai ; i++){
for (int j=1 ; j<=i ; j++){
kar=kar+j;}
kar=kar+"\n";}
JOptionPane.ShowMessageDialog (null,kar);
}
}
}

Iklan

Tentang ahmadrivan

do the best and be the best
Pos ini dipublikasikan di Tulisan. Tandai permalink.

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