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

report raspberry pi

    The raspberry pi is too slow sometimes cannot use the
internet. When coding it too slow. It cannot change the
language.

lab raspberry pi

class Student:
    def __init__(self,name,ID,score):
        self.name = name
        self.score = score
        self.ID = ID
    def get_name(self):
        return self.name
    def get_score(self):
        return self.score
    def get_ID(self):
        return self.ID
    def display_data(self):
        print('Name',self.name)
        print('ID',self.ID)
        print('score',self.score)
def caculation_gragd(data,index):
    print('Grade :' ,end = ' ')
    if(data[index].get_score() >= 80 ):
        print('A')
    elif(data[index].get_score() >=70 ):
        print('B')
    elif(data[index].get_score() >=60 ):
        print('C')
    elif(data[index].get_score() >=50 ):
        print('D')
    elif(data[index].get_score() < 50 ):
        print('F')
def count_grad_a(data):
    index = 0
    count = 0
    while(index<len(data)):
        if(data[index].get_score() >= 80):
            count += 1
        index = index + 1
    return count  
def count_grad_b(data):
    index = 0
    count = 0
    while(index<len(data)):
        if(data[index].get_score() >= 70 and data[index].get_score() <= 79):
            count += 1
        index = index + 1
    return count  
def count_grad_c(data):
    index = 0
    count = 0
    while(index<len(data)):
        if(data[index].get_score() >= 59 and data[index].get_score() <= 69):
            count += 1
        index = index + 1
    return count  
def count_grad_d(data):
    index = 0
    count = 0
    while(index<len(data)):
        if(data[index].get_score() >= 50 and data[index].get_score()<= 58 ):
            count += 1
        index = index + 1
    return count  
def count_grad_f(data):
    index = 0
    count = 0
    while(index<len(data)):
        if(data[index].get_score() < 50):
            count += 1
        index = index + 1
    return count  
           
def show_each_grade(data,ID):
    index = -1
    find = False
    while(index<len(data) and not (find)):
        if(data[index].get_ID() == ID):
            find = True
        index = index + 1
    index -= 1
    if(data[index].get_score() >= 80 ):
        grade = 'A'
    elif(data[index].get_score() >=70 ):
        grade = 'B'
    elif(data[index].get_score() >=60 ):
        grade = 'C'
    elif(data[index].get_score() >=50 ):
        grade = 'D'
    elif(data[index].get_score() < 50 ):
        grade = 'F'
    print('NAME ',data[index].get_name())
    print('SCORE ',data[index].get_score())
    print('GRADE ',grade)
   
   
def setup():
    index = 0
    data = [Student('ant',1,60),
            Student('bird',2,70),
            Student('cat',3,81),
            Student('dog',4,78),
            Student('fish',5,56)]
    while(index<len(data)):
        data[index].display_data()
        caculation_gragd(data,index)
        index = index + 1
    print('Grade A ',count_grad_a(data))
    print('Grade B ',count_grad_b(data))
    print('Grade C ',count_grad_c(data))
    print('Grade D ',count_grad_d(data))
    print('Grade F ',count_grad_f(data))
    show_each_grade(data,3)
setup()  

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

lab 8 bannner by java


public class Banner {

    private String word;
    private char font;

    public Banner(String word, char font) {
        this.word = word;
        this.font = font;

    }

    public void display() {
        String a1 = "   ########    ";
        String a2 = "   ##    ##    ";
        String a3 = "   ##    ##    ";
        String a4 = "   ########    ";
        String a5 = "   ##    ##    ";
        String[] letter_a = {a1, a2, a3, a4, a5};
        String n1 = "   ##       ##  ";
        String n2 = "   ## #     ##  ";
        String n3 = "   ##   #   ##  ";
        String n4 = "   ##     # ##  ";
        String n5 = "   ##       ##  ";
        String[] letter_n = {n1, n2, n3, n4, n5};
        String t1 = "   ##########  ";
        String t2 = "       ##      ";
        String t3 = "       ##      ";
        String t4 = "       ##      ";
        String t5 = "       ##      ";
        String[] letter_t = {t1, t2, t3, t4, t5};
        int index_a = 0;
        change_font(letter_a, '#', this.font);
        change_font(letter_n, '#', this.font);
        change_font(letter_t, '#', this.font);
        while (index_a < 5) {
            int index_n = 0;
            while (index_n < this.word.length()) {
                if (this.word.charAt(index_n) == 'A') {
                    System.out.print(letter_a[index_a]);
                } else if (this.word.charAt(index_n) == 'N') {
                    System.out.print(letter_n[index_a]);
                } else if (this.word.charAt(index_n) == 'T') {
                    System.out.print(letter_t[index_a]);
                }
                index_n = index_n + 1;
            }
            System.out.println();
            index_a = index_a + 1;
        }
    }

    public void set_font(char font) {
        this.font = font;
    }

    public static void main(String[] args) {
        String word = "ANT";
        Banner B = new Banner(word, '#');
        B.display();
        B.set_font('O');
        B.display();
    }

    public static void change_font(String[] letter, char font, char last_font) {
        int index = 0;
        while (index < letter.length) {
            String change_font = "";
            int index2 = 0;
            while (index2 < letter[index].length()) {
                if (letter[index].charAt(index2) == font) {
                    change_font += last_font;
                } else {
                    change_font += " ";
                }
                index2 += 1;
            }
            letter[index] = change_font;
            index += 1;

        }
    }
}

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

lab 8 display age by sort (java)

public class Student {

  private String name;

  private int weight;
 
  private int high;
 
  private int age;

  private int ID;

  public  Student(String name , int weight , int high , int age , int ID ) {
   
   this.name = name ;
   
    this.weight = weight;
   
    this.high = high;
   
    this.age = age;
   
    this.ID = ID;
   }
  public String get_name(){
    return this.name;
  }
  public int get_weight(){
    return this.weight;
  }
  public int get_high(){
    return this.high;
  }
  public int get_age(){
    return this.age;
  }
  public int get_ID(){
    return this.ID;
  }
  public void set_name(String value){
    this.name = value;
  }
  public void set_weight(int  value){
    this.weight =  value;
  }
  public void set_high(int  value){
    this.high = value;
  }
  public void set_age(int  value){
    this.age =  value;
  }
  public void set_ID(int  value){
    this.ID = value;
  }

  public void display() {

    System.out.println( "NAME: "+this.name);
    System.out.println( "WEIGHT:"+this.weight+"  kg.");
    System.out.println( "HIGH:"+this.high+"  cm.");
    System.out.println( "AGE :"+this.age+"  years old");
    System.out.println( "ID :"+this.ID);

 }
  public static void main(String[] args) {
    Student[] std = {new Student("Park",40,160,18,1),
                    new Student("Nani",50,180,19,2),
                     new Student("Pepe",80,185,20,3),
                     new Student("Giggs",70,160,18,4),
                     new Student("Laws",85,155,18,5)};
    sort_age(std);
    int index = 0;
   
    while(index<std.length){
      std[index].display();
      index = index + 1;
    }
 
  }
   public static void sort_age(Student[] std){
    int index  = 1 ;
    while(index<std.length){
      String value_name = std[index].get_name();
      int value_weight = std[index].get_weight();
      int value_high = std[index].get_high();
      int value_age = std[index].get_age();
      int value_ID = std[index].get_ID();
      int pos = index ;
      while(pos>0 &&std[pos - 1].get_age()>value_age){
         std[pos].set_name(std[pos - 1].get_name());
         std[pos].set_weight(std[pos - 1].get_weight());
         std[pos].set_high(std[pos - 1].get_high());
         std[pos].set_age(std[pos - 1].get_age());
         std[pos].set_ID(std[pos - 1].get_ID());
         pos = pos - 1;
      }
      if(pos != index){
         std[pos].set_name(value_name);
         std[pos].set_weight(value_weight);
         std[pos].set_high(value_high);
         std[pos].set_age(value_age);
         std[pos].set_ID(value_ID);
      }
     index = index + 1;
    }
   
   }
}

วันเสาร์ที่ 7 พฤศจิกายน พ.ศ. 2558

lab 8 find count age that less than 30 years old and average age by java

public class Student {

  private String name;

  private int weight;
 
  private int high;
 
  private int age;

  private int ID;

  public  Student(String name , int weight , int high , int age , int ID ) {
   
   this.name = name ;
   
    this.weight = weight;
   
    this.high = high;
   
    this.age = age;
   
    this.ID = ID;
   }
  public int get_age(){
    return this.age;
  }

  public void display() {

    System.out.println( "NAME: "+this.name);
    System.out.println( "WEIGHT:"+this.weight+"  kg.");
    System.out.println( "HIGH:"+this.high+"  cm.");
    System.out.println( "AGE :"+this.age+"  years old");
    System.out.println( "ID :"+this.ID);

 }
  public static void main(String[] args) {
    Student[] std = {new Student("Park",40,160,18,1),
                    new Student("Nani",50,180,19,2),
                     new Student("Pepe",80,185,20,3),
                     new Student("Giggs",70,160,18,4),
                     new Student("Laws",85,155,18,5)};
    int index = 0;
    while(index<std.length){
      std[index].display();
      index = index + 1;
    }
    System.out.println("Average age is  "+average_age(std)+"  years old");
    System.out.println("The number of students that have age less than 30 years old is  "+count_age(std));
  }
  public static float average_age(Student[] std){
    int index = 0;
   float sum_age = 0;
   float age = 0;
    while(index<std.length){
      sum_age += std[index].get_age();
      index = index + 1;
    }
    age = (sum_age)/5 ;
     return age;
  }
  public static int count_age(Student[] std){
   int index  = 0 ;
    int count  = 0;
    while(index<std.length){
      if(std[index].get_age()<30){
        count +=1;
      }
      index  = index + 1;
    }
    return count ;
  }

}

lab 8 find count and display the minimum weight by java

public class Student {
  private String name;
  private int weight;
  private int high;
  private int age;
  private int ID;
  public  Student(String name ,int weight , int high , int age , int ID) {
    this.name = name ;
    this.weight = weight;
    this.high = high;
    this.age = age;
    this.ID = ID;
   }
   public int get_weight(){
    return this.weight;
  }
  public void display() {
    System.out.println( "NAME: "+this.name);
    System.out.println( "WEIGHT:"+this.weight+"  kg.");
    System.out.println( "HIGH:"+this.high+"  cm.");
    System.out.println( "AGE :"+this.age+"  years old");
    System.out.println( "ID :"+this.ID);
}
public static void main(String[] args) {
    Student[] std = {new Student("Park",40,160,18,1),
                    new Student("Nani",50,180,19,2),
                     new Student("Pepe",80,185,20,3),
                     new Student("Giggs",70,160,18,4),
                     new Student("Laws",85,155,18,5)
                    };
    int index = 0;
     while(index<std.length){
      std[index].display();
      index = index + 1;

    }
 System.out.println("The number of students that have weight less than 50 kg. is "+count_weight(std));
   System.out.println( "The minimum weight is  " +find_minimum_weight( std)+"  kg. ");
    }
   public static int count_weight(Student[] std){
    int index = 0 ;
    int count = 0 ;
      while(index<std.length){
      if(std[index].get_weight()<50){
          count +=1 ;
      }
          index = index + 1 ;
      }
        return count    ;
      }
  public static int find_minimum_weight(Student[] std){
    int  index = 0;
    int weight = 100;
    while(index<std.length){
      if(std[index].get_weight()<weight){
        weight = std[index].get_weight();
      }
      index = index + 1;
    }
    return weight;
  }
    }
     



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

lab 8 calculation of bmi by lava

public class Student {
  private String name;
  private float weight;
  private float high;
  private int age;
  private int ID;
  public  Student(String name , int weight , int high , int age , int ID ) {
    this.name = name ;
    this.weight = weight;
    this.high = high;
    this.age = age;
    this.ID = ID;
   }
  public float get_high(){
    return this.high;
  }
  public float get_weight(){
    return this.weight;
  }
  public void display() {
    System.out.println( "NAME: "+this.name);
    System.out.println( "WEIGHT:"+this.weight+"  kg.");
    System.out.println( "HIGH:"+this.high+"  cm.");
    System.out.println( "AGE :"+this.age+"  years old");
    System.out.println( "ID :"+this.ID);
}
public static void main(String[] args) {
    Student[] std = {new Student("Park",40,160,18,1),
                    new Student("Nani",50,180,19,2),
                     new Student("Pepe",80,185,20,3),
                     new Student("Giggs",70,160,18,4),
                     new Student("Laws",85,155,18,5)
                    };
 
    int index = 0;
    while(index<std.length){
      std[index].display();
      System.out.println("BMI "+calculation_of_bmi (std[index] ));
   
      index = index + 1;

    }
    System.out.println("Number of students that have bmi more than 25 is "+count_bmi(std));
  }
public static float calculation_of_bmi (Student Student){
   float  highM = Student.get_high() / 100;
   float bmi = Student.get_weight()/(highM*highM);
    return bmi ;
  }

  public static int count_bmi(Student[] student){
    int index = 0 ;
    int count = 0 ;
      while(index<student.length){
      if(calculation_of_bmi (student[index])>25){
          count +=1 ;
      }
          index = index + 1 ;
      }
        return count    ;
      }
    }





  
  

lab 8 data by java

public class Student {
 
  private String name;
 
  private int weight;
   
  private int high;
   
  private int age;
 
  private int ID;

  public  Student(String name , int weight , int high , int age , int ID ) {
     
  this.name = name ;
     
    this.weight = weight;
     
    this.high = high;
     
    this.age = age;
     
    this.ID = ID;
   }
 
  public void display() {

    System.out.println( "NAME: "+this.name);
    System.out.println( "WEIGHT:"+this.weight+"  kg.");
    System.out.println( "HIGH:"+this.high+"  cm.");
    System.out.println( "AGE :"+this.age+"  years old");
    System.out.println( "ID :"+this.ID);

 }
  public static void main(String[] args) {
    Student[] std = {new Student("Park",40,160,18,1),
                    new Student("Nani",50,180,19,2),
                     new Student("Pepe",80,185,20,3),
                     new Student("Giggs",70,160,18,4),
                     new Student("Laws",85,155,18,5)};
    int index = 0;
    while(index<std.length){
      std[index].display();
      index = index + 1;
    }
  }
}


 
 

lab 7 string

class letter():
    def __init__(self,word,font):
        self.word = word
        self.font = font
    def display(self):
        a1 = "   ########    "
        a2 = "   ##    ##    "
        a3 = "   ##    ##    "
        a4 = "   ########    "
        a5 = "   ##    ##    "
        letter_a = [a1,a2,a3,a4,a5]
        n1 = "   ##       ##  "
        n2 = "   ## #     ##  "
        n3 = "   ##   #   ##  "
        n4 = "   ##     # ##  "
        n5 = "   ##       ##  "
        letter_n = [n1,n2,n3,n4,n5]
        t1 = "   ##########  "
        t2 = "       ##      "
        t3 = "       ##      "
        t4 = "       ##      "
        t5 = "       ##      "
        letter_t = [t1,t2,t3,t4,t5]
        index_a = 0
        change_font(letter_a,"#",self.font)
        change_font(letter_n,"#",self.font)
        change_font(letter_t,"#",self.font)
        while(index_a < 5):
            index_n = 0
            while(index_n < len(self.word)):
                if(self.word[index_n]=="A"):
                    print(letter_a[index_a], end =" ")
                elif(self.word[index_n] =="N"):
                    print(letter_n[index_a], end = " ")
                elif(self.word[index_n] =="T"):
                    print(letter_t[index_a], end = " ")
                index_n = index_n + 1
            print()
            index_a = index_a + 1
    def set_font(self,font):
        self.font = font
def setup():
    word = "ANT"
    B = letter(word,"#")
    B.display()
    B.set_font("*")
    B.display()
def change_font(letter,font,last_font):
   index = 0
   while(index<len(letter)):
      change_font = ""
      index2 = 0
      while(index2<len(letter[index])):
         if(letter[index][index2] == font):
            change_font += last_font
         else:
            change_font += " "
         index2 += 1
      letter[index] = change_font
      index += 1
setup()

lab 7 display data sort by age

class student():
    def __init__(self,name,weight,high,age,ID):
        self.name = name
        self.weight = weight
        self.high = high
        self.age = age
        self.ID = ID
       
    def show_data(self):
        print("Name",self.name)
        print("Weight",self.weight)
        print("High",self.high)
        print("Age",self.age)
        print("ID",self.ID)

    def get_age(self):
        return self.age
    def get_name(self):
        return self.name
    def get_weight(self):
        return self.weight
    def get_high(self):
        return self.high
    def get_ID(self):
        return self.ID
    def set_age(self,value):
        self.age = value
     
    def set_name(self,value):
        self.name = value
     
    def set_weight(self,value):
        self.weight = value
     
    def set_high(self,value):
        self.high = value
       
    def set_ID(self,value):
        self.ID = value
   
def sort_insertion(data):
    index = 1
    while(index<len(data)):
        value_age = data[index].get_age()
        value_name = data[index].get_name()
        value_weight = data[index].get_weight()
        value_high = data[index].get_high()
        value_ID = data[index].get_ID()
        pos = index
        while((pos>0)and (data[pos - 1].get_age()>value_age)):
            data[pos].set_age(data[pos - 1].get_age())
            data[pos].set_name(data[pos - 1].get_name())
            data[pos].set_weight(data[pos - 1].get_weight())
            data[pos].set_high(data[pos - 1].get_high())
            data[pos].set_ID(data[pos - 1].get_ID())
            pos = pos - 1
        if(pos !=index):
            data[pos].set_age(value_age)
            data[pos].set_name(value_name)
            data[pos].set_weight(value_weight)
            data[pos].set_high(value_high)
            data[pos].set_ID(value_ID)
        index = index +1
    return data  
def setup():
    index= 0
    data = [student("Keane",50,185,18,1),
            student("Giggs",55,175,19,2),
            student("Nani",40,160,20,3),
            student("Park",45,169,18,4),
            student("Rooney",80,150,20,5)]
    sort_insertion(data)
    while(index<len(data)):
        data[index].show_data()
        index = index + 1
 
setup()

lab 7 display average,display find and count age that less than 30

class student():
    def __init__(self,name,weight,high,age,ID):
        self.name = name
        self.weight = weight
        self.high = high
        self.age = age
        self.ID = ID

    def show_data(self):
        print("Name",self.name)
        print("Weight",self.weight)
        print("High",self.high)
        print("Age",self.age)
        print("ID",self.ID)
    def get_age(self):
        return self.age
def age(data):
     age = data.get_age()
     return age
def average_age(data):
     index = 0
     summation = 0
     while(index<len(data)):
         summation += age(data[index])/4
         index = index + 1
     return summation
def find_age(data):    
     index = 0
     while(index<len(data)):
         if(age(data[index])<30):
             print(age(data[index]),end = "  ")
         index = index +  1
def count_age(data):
    index = 0
    count = 0
    while(index<len(data)):
        if(age(data[index])<30):
            count +=1
        index = index + 1
    return count  
def setup():
    index= 0
    data = [student("Keane",50,185,18,1),
            student("Giggs",55,175,19,2),
            student("Nani",40,160,20,3),
            student("Park",45,169,18,4),
            student("Rooney",80,150,20,5)]
    while(index<len(data)):
        data[index].show_data()
        index = index + 1
    print("Average age is",average_age(data),"years old")
    print("Display the age that under 30 years old")  
    find_age(data)
    print()
    print("The number of age that under 30 years old is",count_age(data))
   
setup()  

lab 7 find minimum weight, find count and displat weight that < 50

class student():
    def __init__(self,name,weight,high,age,ID):
        self.name = name
        self.weight = weight
        self.high = high
        self.age = age
        self.ID = ID

    def show_data(self):
        print("Name",self.name)
        print("Weight",self.weight)
        print("High",self.high)
        print("Age",self.age)
        print("ID",self.ID)
    def get_weight(self):
        return self.weight
def weight(data):
    weight = data.get_weight()
    return weight
def find_minimum_weight(data):
    index = 0
    minimum =100
    while(index<len(data)):
        if(weight(data[index])< minimum):
            minimum = weight(data[index])
        index = index + 1
    return minimum  
def show_weight(data):
    index = 0
    while(index<len(data)):
        if(weight(data[index])<50):
            print(weight(data[index]),end = "  ")
        index = index + 1
def count_weight(data):
    index = 0
    count = 0
    while(index<len(data)):
        if(weight(data[index])<50):
            count += 1
        index = index + 1
    return count  
def setup():
    index= 0
    data = [student("Keane",50,185,18,1),
            student("Giggs",55,175,19,2),
            student("Nani",40,160,20,3),
            student("Park",45,169,18,4),
            student("Rooney",80,150,20,5)]
    while(index<len(data)):
        data[index].show_data()
        index  = index + 1
    print("Display the weight that less than 50 kg.")  
    show_weight(data)
    print()
    print("Number of students that have weight less than 50 kg.  is ",count_weight(data))
    print("The minimum weight is ",find_minimum_weight(data),"kg.")
setup()  

lab 7 display data , find count bmi >25 and display bmi

class student():
    def __init__(self,name,weight,high,age,ID):
        self.name = name
        self.weight = weight
        self.high = high
        self.age = age
        self.ID = ID

    def show_data(self):
        print("Name",self.name)
        print("Weight",self.weight)
        print("High",self.high)
        print("Age",self.age)
        print("ID",self.ID)
    def get_weight(self):
        return self.weight
    def get_high(self):
        return self.high
def calculation(data):
    highM = data.get_high()/100
    bmi = data.get_weight()/(highM*highM)
    return bmi
def find_bmi(data):
    index = 0
    count = 0
    while(index<len(data)):
        if(calculation(data[index])>25):
            count +=1
        index = index + 1  
    return count      
           
       
def setup():
    index= 0
    data = [student("Keane",50,185,18,1),
            student("Giggs",55,175,19,2),
            student("Nani",40,160,20,3),
            student("Park",45,169,18,4),
            student("Rooney",80,150,20,5)]
    while(index<len(data)):
        data[index].show_data()
        print("BMI ",calculation(data[index]))
        index = index + 1
    print("The number of student that have bmi more than 25 is ",find_bmi(data))  
setup()