°o.O[P]in[K]-[M]oo[N]O.o°

::ภาษา JAVA::...++การบ้าน lab4 credit พี่เอกห้อง 2 ++...



public class lab4_1
{
public static void main(String[] args)
{
int x,y;
for (x=1;x<=6 ;x++ )
{
for (y=1;y<=x ;y++ )
{
System.out.print("*");
}
System.out.println();
}
}
}



-----------------------------------------------------------------------------

import javax.swing.JOptionPane;
public class lab4_2
{
public static void main(String[] args)
{
String input = JOptionPane.showInputDialog(null,"Enter number");
int x = Integer.parseInt(input);
int by;
int count = 0;
for (by = 1; by <=x; by++ )
{
if (x%by == 0)
{
//System.out.println(by);
count++;
}
}
if (count == 2)
{
JOptionPane.showMessageDialog(null,x+" is prime");
}
else
{
JOptionPane.showMessageDialog(null,x+" is not prime");
}
}
}


-----------------------------------------------------------------------------

public class lab4_3
{
public static void main(String[] args)
{
int i = 1;
int j = 1;
int k = 0;
System.out.println(i);
System.out.println(j);
while ( k < 30)
{
k = i + j ;
System.out.println(k);
i = j;
j = k;
}

}
}

----------------------------------------------------------------------------

public class lab4_4
{
public static void main(String[] args)
{
int count = 0;
for (int x = 0; x < 50; x++ )
{
System.out.println("Count is"+count);
count++;
}
}
}

-----------------------------------------------------------------------------

import java.util.Scanner;
public class lab4_5
{
public static void main(String[] args)
{
int guess;
int count = 0;
Scanner scan = new Scanner(System.in);
System.out.println("t*****************nWelcome to the Guessing Gament*****************");
int number = (int)(Math.random()*10);
System.out.println(number);
do
{
System.out.print("Enter an int form 1 to 10 : ");
guess = scan.nextInt();
count++;
if (guess != number)
{
System.out.println("Try again...");
}
}
while (guess != number);

System.out.println("Number is "+number+"nYou win after "+count+" guesses.");
}
}

-----------------------------------------------------------------------------




 

Create Date : 16 กรกฎาคม 2551
0 comments
Last Update : 16 กรกฎาคม 2551 13:47:40 น.
Counter : 976 Pageviews.

ชื่อ :
Comment :
  *ใช้ code html ตกแต่งข้อความได้เฉพาะสมาชิก
 


หนูเดินบนเส้นทางอันโดดเดี่ยว




เราจักภูมิใจ...ในชีวิต

ถ้าโกรธกับเพื่อน.....มองคนไม่มีใครรัก
ถ้าเรียนหนักๆ.....มองคนอดเรียนหนังสือ
ถ้างานลำบาก.....มองคนอดแสดงฝีมือ
ถ้าเหนื่อยงั้นหรือ.....มองคนที่ตายหมดลม
ถ้าขี้เกียจนัก.....มองคนไม่มีโอกาส
ถ้างานผิดพลาด.....มองคนไม่เคยฝึกฝน
ถ้ากายพิการ.....มองคนไม่เคยอดทน
ถ้างานรีบรน.....มองคนไม่มีเวลา
ถ้าตังค์ไม่มี.....มองคนขอทานข้างถนน
ถ้าหนี้สินล้น.....มองคนแย่งกินกับหมา
ถ้าข้าวไม่ดี.....มองคนไม่มีที่นา
ถ้าใจอ่อนล้า.....มองคนไม่รู้จักรัก
ถ้าชีวิตแย่.....จงมองคนแย่ยิ่งกว่า
อย่ามองแต่ฟ้า.....ที่สูงเกินตาประจักษ์
ความสุขข้างล่าง.....มีได้ไม่ยากเย็นนัก
เมื่อรู้แล้วจัก.....ภาคภูมิชีวิตแห่งตน

Location :
นครสวรรค์ Thailand

[ดู Profile ทั้งหมด]

ฝากข้อความหลังไมค์
Rss Feed
Smember
ผู้ติดตามบล็อก : 1 คน [?]





When I miss you,I just close my eyes::ยามใดที่ฉันคิดถึงเธอ ฉันจะเจอเธอได้เพียงหลับตา

°o.O[P]in[K]-[M]oo[N]O.o°




Group Blog
 
<<
กรกฏาคม 2551
 
 12345
6789101112
13141516171819
20212223242526
2728293031 
 
16 กรกฏาคม 2551
 
All Blogs
 
Friends' blogs
[Add หนูเดินบนเส้นทางอันโดดเดี่ยว's blog to your web]
Links
 

 Pantip.com | PantipMarket.com | Pantown.com | © 2004 BlogGang.com allrights reserved.