2. คำนวณ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 2-5  ตัวอย่างการคำนวณพื้นที่ของวงกลมรัศมี 4 หน่วยโดยใช้ตัวแปร
public class CircleArea {
  public static void main(String[] args) {
    int    r  = 4;
    double pi = 3.14159;
    String s  = "วงกลมที่มีรัศมี 4 หน่วย มีพื้นที่  ";
    double area = pi * r * r;
    System.out.println(s + area);
  }
}
©2009 S.Prasitjutrakul