14
Dec
09

Syntax pengulangan di Java dengan JOptionPane


package belajar2g.tugas1;
import javax.swing.JOptionPane;

/**
*
* @author elie
*/
public class programku {
private static int messageType;
public static void main (String [] args){
double luas = 0;

String nil = JOptionPane.showInputDialog(“Masukkan Pilihan Anda : \n 1 = Luas Segitiga ” +
“\n 2 = Luas Persegi Panjang \n 3 = Luas Kubus \n 4 = Luas Lingkaran”);
if (nil.equals(“1”)){
String alas = JOptionPane.showInputDialog(“Masukkan alas :”);
int a = Integer.parseInt(alas) ;
String tinggi = JOptionPane.showInputDialog(“Masukkan Tinggi”);
int t = Integer.parseInt(tinggi);

luas = 0.5*a*t;

JOptionPane.showMessageDialog(null, luas);

}
if (nil.equals(“2”)){
String panjang = JOptionPane.showInputDialog(“Masukkan panjang :”);
int p = Integer.parseInt(panjang) ;
String lebar = JOptionPane.showInputDialog(“Masukkan lebar”);
int l = Integer.parseInt(lebar);

luas = p*l;

JOptionPane.showMessageDialog(null, luas);

}
if (nil.equals(“3”)){
String sisi = JOptionPane.showInputDialog(“Masukkan sisi :”);
int s = Integer.parseInt(sisi) ;

luas = s*s*s;

JOptionPane.showMessageDialog(null, luas);}
if (nil.equals(“4”)){
String Lingkaran =JOptionPane.showInputDialog(“masukkan nilai R”);
int r =Integer.parseInt(Lingkaran);
luas= 3.14*r*r;

JOptionPane.showMessageDialog( null,luas);

}
else
{
JOptionPane.showMessageDialog(null,”Pilihan tidak termasuk dalam katagori”);
}
}
}

Tampilan program :


1 Response to “Syntax pengulangan di Java dengan JOptionPane”


  1. April 5, 2010 at 3:26 am

    benar gak itu syntaxnya


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow My Twitter

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

My Calendar….

December 2009
M T W T F S S
« Sep   Jan »
 123456
78910111213
14151617181920
21222324252627
28293031  

Chat

””

It’s Me….

Man Jadda Wajada...!!!!

(Siapa Yang Bersungguh-Sungguh Akan Berhasil...!!! )

Translate

function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'id'
}, 'google_translate_element');
}


%d bloggers like this: