Chaekyunx’s Weblog “simple informatics cabin”

source code “ngecek prima-prima”

Posted on: November 6, 2008

<!– /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:””; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:”Times New Roman”; mso-fareast-font-family:”Times New Roman”;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} –>


/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:””;
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:”Times New Roman”;
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}

import javax.swing.*;

public class cobaprima

{

public static void main( String args[] ) {

int input1;

int input2;

int array [];

int isi=0;

array= new int [1000];

int i=0;

String input1String;

String input2String;

String keluaran=””;

JOptionPane.showMessageDialog

(null,”bilangan I < bilangan II”+”\n”+” 2 <= bilangan I <= bilangan II <= 10000″, “Aturan”,JOptionPane.INFORMATION_MESSAGE);

input1String = JOptionPane.showInputDialog

( “Masukkan bilangan bulat pertama : ” );

input1=Integer.parseInt( input1String );

input2String = JOptionPane.showInputDialog

( “Masukkan bilangan bulat kedua : ” );

input2=Integer.parseInt( input2String );

if (input2-input1<50&&2<=input1&&input1<=input2&&input2<=10000)

{

for ( int bil=input1;bil<=input2;bil++)

{

int prima=1;

if (bil==2)

{

prima=1;

}

for (int bagi=2;bagi<=bil/2;bagi++)

{

if( bil%bagi==0)

{

prima=0;

}

}

if (prima==1)

{

array[i]=bil;

i++;

}

}

for (int x=0;x<i;x++)

{

for (int y=0;y<i;y++)

{

String temp = Integer.toString(array[x])+Integer.toString(array[y]);

int angka = Integer.parseInt(temp);

int prima=1;

for (int bagi=2;bagi<=angka/2;bagi++)

{

if( angka%bagi==0)

{

prima=0;

}

}

if (prima==1)

{

// System.out.println(array[x]+” “+array[y]);

//isi=1;

keluaran += array[x]+” “+array[y]+”\n”;

isi=1;

}

}

}

if (isi!=1)

{

//System.out.println(“TIDAK ADA”);

JOptionPane.showMessageDialog

(null,”TIDAK ADA”, “Results”,JOptionPane.INFORMATION_MESSAGE);

}

else

{

keluaran = keluaran + “\n”;

JTextArea outputArea = new JTextArea ();

outputArea.setText(keluaran);

JOptionPane.showMessageDialog(null, outputArea, “results”,JOptionPane.INFORMATION_MESSAGE);

}

}

else

{

JOptionPane.showMessageDialog

(null,”MASUKKAN ANGKA YANG BENAR”, “Peringatan”,JOptionPane.INFORMATION_MESSAGE);

}

System.exit (0);

}

}

di coba ndiri yach,…

nie ngerjainnya ampe malem bgt, pulang dari kampus udah sepiiiiiiiiiii bnaget jalannya,.udah berkabut pula,…

hiii ngeri!!!!


v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
<!– /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:””; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:”Times New Roman”; mso-fareast-font-family:”Times New Roman”;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} –>


/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:””;
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:”Times New Roman”;
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}

3 Tanggapan to "source code “ngecek prima-prima”"

“nie ngerjainnya ampe malem bgt, pulang dari kampus udah sepiiiiiiiiiii bnaget jalannya,.udah berkabut pula,…hiii ngeri!!!!”

lah,,
lebay… :p

hadeuh….apaan ituh???
saya sebagai manusia kok ga bisa baca itu artinya apaan
bukan bahasa manusia pastinya
hehehe

mb dee…
blajar asp.net nuk teu?
bagi2 ilmu na ath…

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

%d blogger menyukai ini: