love

วันอังคารที่ 24 พฤศจิกายน พ.ศ. 2558

Lab Raspberry Pi

Raspberry Pi
-เป็นบอร์ดคอมพิวเตอร์ขนาดเล็กพกพาได้ง่าย สะดวกแก่ารติดตั้ง

ข้อดี
-อันเล็ก เก็บง่าย สะดวกแก่การติดตั้ง

ข้อเสีย
-ใช้งานยาก จำเป็นต้องมีความรู้การใช้งาน
-ประสิทธิภาพไม่ค่อยดี หาก เทียบกับ คอมพิวเตอร์ชนิด Desktop หรือ Notebook

Python ใน Raspberry Pi เป็นไง
-วิธีเขียนและใช้เหมือนในWindow

สามารถรัน A1 ได้

Scratch เป็นโปรแกรมที่สามารถทำAnimationได้ โดยจะทีชุดคำสั่งแบบสำเร็จรูปมาให้ใช้

Lab8 - Count number of student >50

public class student{
  private String name;
  private int id;
  private int age;
  private float weight;
  private float height;

  public student(String name,int id,int age,float weight,float height){
    this.name = name;
    this.id = id;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }

  public String get_name(){
    return this.name;
  }

  public int get_id(){
    return this.id;
  }

  public int get_age(){
    return this.age;
  }

  public float get_weight(){
    return this.weight;
  }

  public float get_height(){
    return this.height;
  }

  public float get_bmi(){
    float bmi = this.weight/((this.height/100)*(this.height/100));
    return bmi;
  }

  public static void main(String[] args){
    student a = new student("Oat",1,18,52,165);
    student b = new student("Nice",2,19,50,170);
    student c = new student("Loemax",3,19,65,170);
    student d = new student("Shin",4,19,63,168);
    student [] data = {a,b,c,d};

    display(data);
  }

  public static void display(student [] data){
    int count = 0;
    int num =0;
    while(count<data.length){
      if(data[count].get_weight()<50){
        num++;
      }
      count++;
    }
    System.out.println("Number of students with weight<50 : " +num);
  }
}

วันอาทิตย์ที่ 15 พฤศจิกายน พ.ศ. 2558

Lab8 - Find Minimum Weight of Students (Java)

public class student{
  private String name;
  private int id;
  private int age;
  private float weight;
  private float height;

  public student(String name,int id,int age,float weight,float height){
    this.name = name;
    this.id = id;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }

  public String get_name(){
    return this.name;
  }

  public int get_id(){
    return this.id;
  }

  public int get_age(){
    return this.age;
  }

  public float get_weight(){
    return this.weight;
  }

  public float get_height(){
    return this.height;
  }

  public float get_bmi(){
    float bmi = this.weight/((this.height/100)*(this.height/100));
    return bmi;
  }

  public static void main(String[] args){
    student a = new student("Oat",1,18,52,165);
    student b = new student("Nice",2,19,50,170);
    student c = new student("Loemax",3,19,65,170);
    student d = new student("Shin",4,19,63,168);
    student [] data = {a,b,c,d};

    display(data);
  }

  public static void display(student [] data){
    int count = 0;
    float min = data[0].get_weight();
    float compare = 0;
    while(count<data.length){
      compare = data[count].get_weight();
      if(compare<min){
        min = compare;
      }
      count = count+1;
    }
    System.out.println("Minimum Weight of Student : " +min);
  }
}

Lab8 - Number of Student With Age < 30

public class student{
  private String name;
  private int id;
  private int age;
  private float weight;
  private float height;

  public student(String name,int id,int age,float weight,float height){
    this.name = name;
    this.id = id;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }

  public String get_name(){
    return this.name;
  }

  public int get_id(){
    return this.id;
  }

  public int get_age(){
    return this.age;
  }

  public float get_weight(){
    return this.weight;
  }

  public float get_height(){
    return this.height;
  }

  public float get_bmi(){
    float bmi = this.weight/((this.height/100)*(this.height/100));
    return bmi;
  }

  public static void main(String[] args){
    student a = new student("Oat",1,18,52,165);
    student b = new student("Nice",2,19,50,170);
    student c = new student("Loemax",3,19,65,170);
    student d = new student("Shin",4,19,63,168);
    student [] data = {a,b,c,d};

    display(data);
  }

  public static void display(student [] data){
    int count = 0;
    int  age = 0;
    while(count<data.length){
      if(data[count].get_age()<30){
        age ++;
      }
      count = count+1;
    }
    System.out.println("Number of student's age<30 : " +age);
  }
}

Lab8 - Find Average age of Student (Java)

public class student{
  private String name;
  private int id;
  private int age;
  private float weight;
  private float height;

  public student(String name,int id,int age,float weight,float height){
    this.name = name;
    this.id = id;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }

  public String get_name(){
    return this.name;
  }

  public int get_id(){
    return this.id;
  }

  public int get_age(){
    return this.age;
  }

  public float get_weight(){
    return this.weight;
  }

  public float get_height(){
    return this.height;
  }

  public float get_bmi(){
    float bmi = this.weight/((this.height/100)*(this.height/100));
    return bmi;
  }

  public static void main(String[] args){
    student a = new student("Oat",1,18,52,165);
    student b = new student("Nice",2,19,50,170);
    student c = new student("Loemax",3,19,65,170);
    student d = new student("Shin",4,19,63,168);
    student [] data = {a,b,c,d};

    display(data);
  }

  public static void display(student [] data){
    int count = 0;
    int average = 0;
    while(count<data.length){
      average += data[count].get_age();
      count = count+1;
    }
    average = average/data.length;
    System.out.println("Average age of Students : " +average);
  }
}

Lab8 - Count Student Number of BMI > 25 (Java)

public class student{
  private String name;
  private int id;
  private int age;
  private float weight;
  private float height;

  public student(String name,int id,int age,float weight,float height){
    this.name = name;
    this.id = id;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }

  public String get_name(){
    return this.name;
  }

  public int get_id(){
    return this.id;
  }

  public int get_age(){
    return this.age;
  }

  public float get_weight(){
    return this.weight;
  }

  public float get_height(){
    return this.height;
  }

  public float get_bmi(){
    float bmi = this.weight/((this.height/100)*(this.height/100));
    return bmi;
  }

  public static void main(String[] args){
    student a = new student("Oat",1,18,52,165);
    student b = new student("Nice",2,19,50,170);
    student c = new student("Loemax",3,19,65,170);
    student d = new student("Shin",4,19,63,168);
    student [] data = {a,b,c,d};

    display(data);
  }

  public static void display(student [] data){
    int count = 0;
    int count_bmi = 0;
    while(count<data.length){
      if(data[count].get_bmi()>25){
      System.out.println("Name : "+data[count].get_name());
      System.out.println("ID : "+data[count].get_id());
      System.out.println("Age : "+data[count].get_age());
      System.out.println("Weight : "+data[count].get_weight());
      System.out.println("Height : "+data[count].get_height());
      System.out.println("BMI : " +data[count].get_bmi());
      System.out.println();
        count_bmi +=1;
      }
      count = count+1;
    }
    System.out.println("Number of Stuent BMI > 25 : " +count_bmi);
  }
}