วันพฤหัสบดีที่ 20 กันยายน พ.ศ. 2550

week8

string
เป็นการประกาศค่าตัวแปรออกมาเป็นตัวอักษร
การกำหนดให้ String เป็นตัวแปร
โดย String ชื่อตัวแปร = "ข้อความที่ต้องการ"
เช่นString x = "bye"
วิธีนำตัวแปรมาใช้ก็ใช้
System.out.print(ตัวแปร);
ถ้าตามดังเงื่อนไขข้างบนจะได้ว่า
System.out.print(x);

week7

array
ในการประกาศใช้ array มี3ส่วนหลักคือ
-ชนิดของข้อมูล ตัวแปร [];
เช่น int a[];
-ตัวแปร = new ชนิดของข้อมูล [n];
n = จำนวนของความกว้างของ Array
เช่น a = new int [4];
จะได้ว่า Array ที่มีตัวแปร 4 ตัวแปร
-การกำหนดค่าตัวแปร
โดยตัวแปร [n] = ค่าของเลข;
โดยที่ค่าของตัวแปรจะเริ่มจาก 0
เช่น a [0] = 1;a [1] = 2;a [2] = 3;a [3] = 4;
จะได้ตัวแปร
a [0] = 1; a [1] = 2; a[2] = 3; a [3] = 4;

LOOP
คือการวนคำสั่งซำๆ

วันพฤหัสบดีที่ 30 สิงหาคม พ.ศ. 2550

week6

การใช้else
else เป็นการนำคำสั้งของเงื่อนไข เมื่อสิ่งที่มาจาก if=>F

import java.util.*;
public class numberif{
public static void main(String[] args) {
int num1 = new Scanner(System.in).nextInt();
if(num1 == 50) System.out.println(" the number = " + 50);
else if(num1 > 50 ) System.out.println(" the number > 50 ");
else System.out.println(" the number < 50 "); } }

down load
http://www.uploadtoday.com/download/?35a650703f1dbf43ad0eb1b27c32e8be

week5

ประโยคเงื่อนไข
เงื่อนไข คือ ข้อตกลงในการตัดสินใจอะไรสักอย่าง
เช่น
การเป็นคนดีอาจจะมีเงื่อนไขว่า ต้องไม่ทำชั่ว
แต่ถ้าหากทำชั่วก็จะไม่ใช่คนดี
ในjava ใช้ if ถ้าผล =>T จะให้ผลตามที่ตกลง
ถ้าผล =>F จะให้ผลเป็นอย่างอื่นหรือไม่ให้ผล
public class if1 {
public static void main(String[]args) {
int x= 5;
if(x==5) System.out.println("x="+x);
System.out.println("bye bye"); } }
จากสมการข้างต้น ที่ให้x=5
................................................................
public class if2 {
public static void main(String[]args) {
int x= 10;
if(x==5) { System.out.println("x="+x);
System.out.println("Condition=true"); }
else System.out.println("x is not equal to 10");
System.out.println("bye bye"); } }
...............................................................
import java.util.*;
public class if3 {
public static void main(String[]args){
Scanner a = new Scanner(System.in);
int x ;
System.out.print("enter the number : ");
x = a.nextInt();
if(x==120) { System.out.println("x="+x);
System.out.println("jack pot"); }
else System.out.println("fail");
System.out.println("bye bye"); }}

down load here
http://www.uploadtoday.com/download/?25b1e416996157b70053e11c811f6220

week3

เรียน การรวมข้อความ การคำนวณในภาษา java
ตัวอย่างงาน
public class sumScore {
public static void main(String[]args) {
System.out.println(args[0]);
System.out.println("score1="+args[1]);
System.out.println("score2="+args[2]);
System.out.println(Integer.parseInt(args[1])+Integer.parseInt(args[2]));
}
}
down load here
http://www.uploadtoday.com/download/?99a10609b58dc13274ba4608e6389b4b

week2

เรียนรู้ การประมวลผลใน java
public class jak_week2 {
public static void main(String [] args){
System.out.println("Rectangle area = 1/2 * base / hight" );
System.out.println("Base = " + 10 );
System.out.println("Hight = " + 20 );
System.out.println("Rectangle area = " + ( 1.0/2 * 10 * 20 ) );
}
}
down load here
http://www.uploadtoday.com/download/?30a781f4c34e1a5e704829951a1e79f3

วันพฤหัสบดีที่ 5 กรกฎาคม พ.ศ. 2550

week4

การใช้ Scanner run โดย keybord การหาผลรวม ค่าเฉลี่ย
import java.util.*;public class xyz {
public static void main(String[]args) {
Scanner a = new Scanner(System.in);
Scanner b = new Scanner(System.in); Scanner c = new Scanner(System.in);
float x;
float y;
float z;
System.out.print("Score1:");
x=a.nextFloat();
System.out.print("Score2:");
y=b.nextFloat();
System.out.print("Score3:");
z=c.nextFloat();
System.out.println(x);
System.out.println(y);
System.out.println(z);
System.out.println("score1 ="+x);
System.out.println("score2 ="+y);
System.out.println("score3 ="+z);
System.out.println(("sumScore")+(x+y+z));
System.out.println((("Average")+(x+y+z)/3)); }}
dowload
http://www.uploadtoday.com/download/?36993361c9b07dc998d6c3af7c1f5f8d