Tuesday, November 24, 2015

Lab x RaspberryPi - GradeCalculate

class Student:
    def __init__(self,name,id,score):
        self.name = name
        self.id = id
        self.score = score
    def display(self):
        print('Name :',self.name)
        print('ID :',self.id)
        print('Score :',self.score)
    def get_score(self):
        return self.score

def setup():
    a = Student('Ant',1,80)
    b = Student('Bird',2,75)
    c = Student('Cat',3,59)
    d = Student('Dog',4,15)
    e = Student('Elephant',5,62)
    data = [a,b,c,d,e]
    show_allgrade(data)

def find_grade(data):
 
    if(80 <= data.get_score()):
        return 'A'
    elif(70 <= data.get_score()):
        return 'B'
    elif(60 <= data.get_score()):
        return 'C'
    elif(50 <= data.get_score()):
        return 'D'
    else:
        return 'F'

def count_grade(c,data):
    i=0
    count=0
    while(i < len(data)):
        if(find_grade(data[i]) == c):
            count+=1
        i+=1
    return count

def show_allgrade(data):
    i=0
    while(i < len(data)):
        data[i].display()
        print('Grade :',find_grade(data[i]))
        print()
        i+=1
 
setup()
         
     
     
     

Sunday, November 1, 2015

Lab8 - Display student records with weight < 50

public class Student {
  private String name;
  private int studentNumber;
  private int age;
  private int weight;
  private int height;
 
  public Student(String name, int studentNumber, int age, int weight, int height) {
    this.name = name;
    this.studentNumber = studentNumber;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }
 
  public String display_name() {
    return this.name;
  }
 
  public int display_studentNumber() {
  return this.studentNumber ;
  }
 
  public int display_age(){
    return this.age;
  }
 
  public float display_weight() {
    return this.weight;
  }
 
  public float display_height() {
    return this.height;
  }
 
 
  public static void main(String[] args) {
    Student[] stu =  { new Student("Bird", 33, 22, 72, 165 ),
    new Student("Bryant", 24, 21, 58, 167 ),
    new Student("Paul", 3, 17, 69, 166 ),
    new Student("James", 23, 19, 62, 172 ),
        new Student("Nowitzki", 34, 21, 66, 177 ) };
    System.out.println ( " ##### Student Record #####" );
    display_data(stu) ;
  }
 
  public static void display_data(Student[] s) {
    int i=0;
    while (i<s.length) {
      if(50 > s[i].display_weight()) {
        System.out.println( "Name : "+s[i].display_name() );
      System.out.println( "StudentNumber : " +s[i].display_studentNumber() );
      System.out.println( "Age : "+s[i].display_age() );
      System.out.println( "Weight : "+s[i].display_weight() );
      System.out.println( "Height : "+s[i].display_height() );
      System.out.println( "" );
      }
     i=i+1;
    }
  }
}

Lab8 - Find/count number of students with weight < 50

public class Student {
  private String name;
  private int studentNumber;
  private int age;
  private int weight;
  private int height;
 
  public Student(String name, int studentNumber, int age, int weight, int height) {
    this.name = name;
    this.studentNumber = studentNumber;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }
 
  public String display_name() {
    return this.name;
  }
 
  public int display_studentNumber() {
  return this.studentNumber ;
  }
 
  public int display_age(){
    return this.age;
  }
 
  public float display_weight() {
    return this.weight;
  }
 
  public float display_height() {
    return this.height;
  }
 
 
  public static void main(String[] args) {
    Student[] stu =  { new Student("Bird", 33, 22, 72, 165 ),
    new Student("Bryant", 24, 21, 58, 167 ),
    new Student("Paul", 3, 17, 69, 166 ),
    new Student("James", 23, 19, 62, 172 ),
        new Student("Nowitzki", 34, 21, 66, 177 ) };
    System.out.println ( " ##### Student Record #####" );
    display_data(stu) ;
  }
 
  public static void display_data(Student[] s) {
    int count=0;
    int i=0;
    while (i<s.length) {
      if(50 > s[i].display_weight()) {
        count = count+1;
      }
     i=i+1;
    }
  System.out.println( "Number of students with weight < 50 is "+count );
  }
}

Lab8 - Find minimum weight of students

public class Student {
  private String name;
  private int studentNumber;
  private int age;
  private int weight;
  private int height;
 
  public Student(String name, int studentNumber, int age, int weight, int height) {
    this.name = name;
    this.studentNumber = studentNumber;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }
 
  public String display_name() {
    return this.name;
  }
 
  public int display_studentNumber() {
  return this.studentNumber ;
  }
 
  public int display_age(){
    return this.age;
  }
 
  public float display_weight() {
    return this.weight;
  }
 
  public float display_height() {
    return this.height;
  }
 
 
  public static void main(String[] args) {
    Student[] stu =  { new Student("Bird", 33, 22, 72, 165 ),
    new Student("Bryant", 24, 21, 58, 167 ),
    new Student("Paul", 3, 17, 69, 166 ),
    new Student("James", 23, 19, 62, 172 ),
        new Student("Nowitzki", 34, 21, 66, 177 ) };
    System.out.println ( " ##### Student Record #####" );
    display_data(stu) ;
  }
 
  public static void display_data(Student[] s) {
    int i=0;
    float reference=s[i].display_weight();
    while (i<s.length) {
      if( reference>s[i].display_weight() ) {
        reference=s[i].display_weight();
      }
      i=i+1;
    }
  System.out.println( "Minimum weight of students is "+reference );
  }
}

Lab8 - Find/count number of students with age < 30

public class Student {
  private String name;
  private int studentNumber;
  private int age;
  private int weight;
  private int height;
 
  public Student(String name, int studentNumber, int age, int weight, int height) {
    this.name = name;
    this.studentNumber = studentNumber;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }
 
  public String display_name() {
    return this.name;
  }
 
  public int display_studentNumber() {
  return this.studentNumber ;
  }
 
  public int display_age(){
    return this.age;
  }
 
  public float display_weight() {
    return this.weight;
  }
 
  public float display_height() {
    return this.height;
  }
 
 
  public static void main(String[] args) {
    Student[] stu =  { new Student("Bird", 33, 22, 72, 165 ),
    new Student("Bryant", 24, 21, 58, 167 ),
    new Student("Paul", 3, 17, 69, 166 ),
    new Student("James", 23, 19, 62, 172 ),
        new Student("Nowitzki", 34, 21, 66, 177 ) };
    System.out.println ( " ##### Student Record #####" );
    display_data(stu) ;
  }
 
  public static void display_data(Student[] s) {
    int count=0;
    int i=0;
    while (i<s.length) {
      if(s[i].display_age()<30) {
        count = count+1;
      }
      i=i+1;
    }
  System.out.println( "Number of students with age < 30 is "+count );
  }
}

Lab8 - Find average age of students

public class Student {
  private String name;
  private int studentNumber;
  private int age;
  private int weight;
  private int height;
 
  public Student(String name, int studentNumber, int age, int weight, int height) {
    this.name = name;
    this.studentNumber = studentNumber;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }
 
  public String display_name() {
    return this.name;
  }
 
  public int display_studentNumber() {
  return this.studentNumber ;
  }
 
  public int display_age(){
    return this.age;
  }
 
  public float display_weight() {
    return this.weight;
  }
 
  public float display_height() {
    return this.height;
  }
 
 
  public static void main(String[] args) {
    Student[] stu =  { new Student("Bird", 33, 22, 72, 165 ),
    new Student("Bryant", 24, 21, 58, 167 ),
    new Student("Paul", 3, 17, 69, 166 ),
    new Student("James", 23, 19, 62, 172 ),
        new Student("Nowitzki", 34, 21, 66, 177 ) };
    System.out.println ( " ##### Student Record #####" );
    display_data(stu) ;
  }
 
  public static void display_data(Student[] s) {
    float sum=0;
    int i=0;
    while (i<s.length) {
     sum = sum+s[i].display_age();
     i=i+1;
    }
  sum = sum/s.length;
  System.out.println( "Average age of students is "+sum );
  }
}

Lab8 - Display student records with BMI > 25

public class Student {
  private String name;
  private int studentNumber;
  private int age;
  private int weight;
  private int height;
 
  public Student(String name, int studentNumber, int age, int weight, int height) {
    this.name = name;
    this.studentNumber = studentNumber;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }
 
  public String display_name() {
    return this.name;
  }
 
  public int display_studentNumber() {
  return this.studentNumber ;
  }
 
  public int display_age(){
    return this.age;
  }
 
  public float display_weight() {
    return this.weight;
  }
 
  public float display_height() {
    return this.height;
  }
 
 
  public static void main(String[] args) {
    Student[] stu =  { new Student("Bird", 33, 22, 72, 165 ),
    new Student("Bryant", 24, 21, 58, 167 ),
    new Student("Paul", 3, 17, 69, 166 ),
    new Student("James", 23, 19, 62, 172 ),
        new Student("Nowitzki", 34, 21, 66, 177 ) };
    System.out.println ( " ##### Student Record #####" );
    display_data(stu) ;
  }
 
  public static void display_data(Student[] s) {
    int count=0;
    float bmi;
    int i=0;
    while (i<s.length) {
      bmi=s[i].display_weight()/((s[i].display_height()/100)*(s[i].display_height()/100));
      if(bmi>25) {
      System.out.println( "Name : "+s[i].display_name() );
      System.out.println( "StudentNumber : " +s[i].display_studentNumber() );
      System.out.println( "Age : "+s[i].display_age() );
      System.out.println( "Weight : "+s[i].display_weight() );
      System.out.println( "Height : "+s[i].display_height() );
      System.out.println("Your BMI is "+bmi);
      System.out.println( "" );
      }
      i=i+1;
    }
  }
}

Lab8 - Find/count number of students with BMI > 25

public class Student {
  private String name;
  private int studentNumber;
  private int age;
  private int weight;
  private int height;
 
  public Student(String name, int studentNumber, int age, int weight, int height) {
    this.name = name;
    this.studentNumber = studentNumber;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }
 
  public String display_name() {
    return this.name;
  }
 
  public int display_studentNumber() {
  return this.studentNumber ;
  }
 
  public int display_age(){
    return this.age;
  }
 
  public float display_weight() {
    return this.weight;
  }
 
  public float display_height() {
    return this.height;
  }
 
 
  public static void main(String[] args) {
    Student[] stu =  { new Student("Bird", 33, 22, 72, 165 ),
    new Student("Bryant", 24, 21, 58, 167 ),
    new Student("Paul", 3, 17, 69, 166 ),
    new Student("James", 23, 19, 62, 172 ),
        new Student("Nowitzki", 34, 21, 66, 177 ) };
    System.out.println ( " ##### Student Record #####" );
    display_data(stu) ;
  }
 
  public static void display_data(Student[] s) {
    int count=0;
    float bmi;
    int i=0;
    while (i<s.length) {
      bmi=s[i].display_weight()/((s[i].display_height()/100)*(s[i].display_height()/100));
      if(bmi > 25) {
        count=count+1;
      }
      i=i+1;
    }
  System.out.println( "Number of students with BMI > 25 is "+count );
  }
}

Lab8 - Find student BMI

public class Student {
  private String name;
  private int studentNumber;
  private int age;
  private int weight;
  private int height;
 
  public Student(String name, int studentNumber, int age, int weight, int height) {
    this.name = name;
    this.studentNumber = studentNumber;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }
 
  public String display_name() {
    return this.name;
  }
 
  public int display_studentNumber() {
  return this.studentNumber ;
  }
 
  public int display_age(){
    return this.age;
  }
 
  public float display_weight() {
    return this.weight;
  }
 
  public float display_height() {
    return this.height;
  }
 
 
  public static void main(String[] args) {
    Student[] stu =  { new Student("Bird", 33, 22, 65, 170 ),
    new Student("Bryant", 24, 21, 58, 167 ),
    new Student("Paul", 3, 17, 57, 167 ),
    new Student("James", 23, 19, 62, 172 ),
        new Student("Nowitzki", 34, 21, 66, 177 ) };
    System.out.println ( " ##### Student Record #####" );
    display_data(stu) ;
  }
 
  public static void display_data(Student[] s) {
    float bmi;
    int i=0;
    while (i<s.length) {
      System.out.println( "Name : "+s[i].display_name() );
      System.out.println( "StudentNumber : " +s[i].display_studentNumber() );
      System.out.println( "Age : "+s[i].display_age() );
      System.out.println( "Weight : "+s[i].display_weight() );
      System.out.println( "Height : "+s[i].display_height() );
      bmi=s[i].display_weight()/((s[i].display_height()/100)*(s[i].display_height()/100));
      System.out.println("Your BMI is "+bmi);
      System.out.println( "" );
      i=i+1;
    }
  }
}

Lab8 - Display each student record

public class Student {
  private String name;
  private int studentNumber;
  private int age;
  private int weight;
  private int height;
 
  public Student(String name, int studentNumber, int age, int weight, int height) {
    this.name = name;
    this.studentNumber = studentNumber;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }
 
  public String display_name() {
    return this.name;
  }
 
  public int display_studentNumber() {
  return this.studentNumber ;
  }
 
  public int display_age(){
    return this.age;
  }
 
  public int display_weight() {
    return this.weight;
  }
 
  public int display_height() {
    return this.height;
  }
 
  public static void main(String[] args) {
    Student[] stu =  { new Student("Bird", 33, 22, 65, 170 ),
    new Student("Bryant", 24, 21, 58, 167 ),
    new Student("Paul", 3, 17, 57, 167 ),
    new Student("James", 23, 19, 62, 172 ),
        new Student("Nowitzki", 34, 21, 66, 177 ) };
    System.out.println ( " ##### Student Record #####" );
    display_data(stu) ;
  }
 
  public static void display_data(Student[] s) {
    int i=0;
    while (i<s.length) {
      System.out.println( "Name : "+s[i].display_name() );
      System.out.println( "StudentNumber : " +s[i].display_studentNumber() );
      System.out.println( "Age : "+s[i].display_age() );
      System.out.println( "Weight : "+s[i].display_weight() );
      System.out.println( "Height : "+s[i].display_height() );
      System.out.println( "" );
      i=i+1;
    }
  }
}

Lab7 - Display student records with weight < 50

class Student:

    def __init__(self,name,id,age,weight,height):
       

        self.name = name

        self.id = id

        self.age = age

        self.weight = weight

        self.height = height


    def display_name(self):
        return self.name
       
    def display_id(self):
        return self.id 
       
    def display_age(self):
        return self.age
       
    def display_weight(self):
        return self.weight
       
    def display_height(self): 
        return self.height

      

def setup():

    a = Student( "Antony" , 11 , 22 , 58 , 165 )

    b = Student( "Mike" , 12 , 23 , 66 , 171 )

    c = Student( "Jacky" , 23 , 21 , 48 , 162 )

    d = Student( "Bank" , 30 , 22 , 57 , 177 )

    e = Student( "Billy" , 1 , 20 , 62 , 180 )

    f = Student( "Biccy" , 3 , 24 , 62 , 181 )

    data = [a,b,c,d,e,f]

    find_minimum(data)


def find_minimum(data):
   
    i=0
   
    while(i < len(data)):
       
        if(50 > data[i].display_weight()):
       
            print("Name : ",data[i].display_name())
       
            print("ID : ",data[i].display_id())
       
            print("Age : ",data[i].display_age())
       
            print("Weight : ",data[i].display_weight())
       
            print("Height : ",data[i].display_height())
           
        i+=1  

setup()

Lab7 - Find/count number of students with weight < 50

class Student:

    def __init__(self,name,id,age,weight,height):
       

        self.name = name

        self.id = id

        self.age = age

        self.weight = weight

        self.height = height


    def display_name(self):
        return self.name
       
    def display_id(self):
        return self.id 
       
    def display_age(self):
        return self.age
       
    def display_weight(self):
        return self.weight
       
    def display_height(self): 
        return self.height

      

def setup():

    a = Student( "Antony" , 11 , 22 , 58 , 165 )

    b = Student( "Mike" , 12 , 23 , 66 , 171 )

    c = Student( "Jacky" , 23 , 21 , 71 , 162 )

    d = Student( "Bank" , 30 , 22 , 57 , 177 )

    e = Student( "Billy" , 1 , 20 , 62 , 180 )

    f = Student( "Biccy" , 3 , 24 , 62 , 181 )

    data = [a,b,c,d,e,f]

    find_minimum(data)


def find_minimum(data):
   
    i=0
   
    count=0
   
    while(i < len(data)):
       
        if(50 > data[i].display_weight()):
           
            count+=1
           
        i+=1
       
    print(" Number of students with weight < 50 is",count)   


setup()

Lab7 - Find minimum weight of students

class Student:

    def __init__(self,name,id,age,weight,height):
       

        self.name = name

        self.id = id

        self.age = age

        self.weight = weight

        self.height = height


    def display_name(self):
        return self.name
       
    def display_id(self):
        return self.id 
       
    def display_age(self):
        return self.age
       
    def display_weight(self):
        return self.weight
       
    def display_height(self): 
        return self.height

      

def setup():

    a = Student( "Antony" , 11 , 22 , 58 , 165 )

    b = Student( "Mike" , 12 , 23 , 66 , 171 )

    c = Student( "Jacky" , 23 , 21 , 71 , 162 )

    d = Student( "Bank" , 30 , 22 , 57 , 177 )

    e = Student( "Billy" , 1 , 20 , 62 , 180 )

    f = Student( "Biccy" , 3 , 24 , 62 , 181 )

    data = [a,b,c,d,e,f]

    find_minimum(data)


def find_minimum(data):
   
    i=0
   
    reference=data[i].display_weight()
   
    while(i < len(data)):
       
        if(reference>data[i].display_weight()):
           
            reference=data[i].display_weight()
           
        i+=1
       
    print("Minimum weight of students is ",reference)   


setup()

Lab7 - Find/count number of students with age < 30

class Student:

    def __init__(self,name,id,age,weight,height):
       

        self.name = name

        self.id = id

        self.age = age

        self.weight = weight

        self.height = height


    def display_name(self):
        return self.name
       
    def display_id(self):
        return self.id 
       
    def display_age(self):
        return self.age
       
    def display_weight(self):
        return self.weight
       
    def display_height(self): 
        return self.height

      

def setup():

    a = Student( "Antony" , 11 , 22 , 71 , 165 )

    b = Student( "Mike" , 12 , 23 , 66 , 171 )

    c = Student( "Jacky" , 23 , 21 , 58 , 162 )

    d = Student( "Bank" , 30 , 22 , 60 , 177 )

    e = Student( "Billy" , 1 , 20 , 62 , 180 )

    f = Student( "Biccy" , 3 , 24 , 62 , 181 )

    data = [a,b,c,d,e,f]

    average_age(data)


def average_age(data):
   
    i = 0
   
    count = 0
   
    while(i < len(data)):
       
        if(data[i].display_age() < 30):
           
            count+=1
           
        i+=1
       
    print("Number of students with age < 30 is ",count)    


setup()

Lab7 - Find average age of students

class Student:

    def __init__(self,name,id,age,weight,height):
       

        self.name = name

        self.id = id

        self.age = age

        self.weight = weight

        self.height = height


    def display_name(self):
        return self.name
       
    def display_id(self):
        return self.id 
       
    def display_age(self):
        return self.age
       
    def display_weight(self):
        return self.weight
       
    def display_height(self): 
        return self.height

      

def setup():

    a = Student( "Antony" , 11 , 22 , 71 , 165 )

    b = Student( "Mike" , 12 , 23 , 66 , 171 )

    c = Student( "Jacky" , 23 , 21 , 58 , 162 )

    d = Student( "Bank" , 30 , 22 , 60 , 177 )

    e = Student( "Billy" , 1 , 20 , 62 , 180 )

    f = Student( "Biccy" , 3 , 24 , 62 , 181 )

    data = [a,b,c,d,e,f]

    average_age(data)


def average_age(data):
   
    i = 0
   
    avg = 0
   
    while(i < len(data)):
       
        avg+=data[i].display_age()
       
        i+=1
       
    avg/=len(data)
   
    avg*=100
   
    avg=round(avg)
   
    avg/=100
   
    print("Average age of students is ",avg)    


setup()

Lab7 - Display student records with BMI > 25

class Student:

    def __init__(self,name,id,age,weight,height):
       

        self.name = name

        self.id = id

        self.age = age

        self.weight = weight

        self.height = height


    def bmi(self):
       
       
        bmi=self.weight/((self.height/100)*(self.height/100))
       
        if(bmi>25):
           
            print("Name : ",self.name)

            print("Weight : ",self.weight)

            print("Height : ",self.height)
           
            print("Your BMI is" ,bmi)

      

def setup():

    a = Student( "Antony" , 11 , 22 , 71 , 165 )

    b = Student( "Mike" , 12 , 23 , 66 , 171 )

    c = Student( "Jacky" , 23 , 21 , 58 , 162 )

    d = Student( "Bank" , 30 , 22 , 60 , 177 )

    e = Student( "Billy" , 1 , 20 , 62 , 180 )

    f = Student( "Biccy" , 3 , 24 , 62 , 181 )

    data = [a,b,c,d,e,f]

    bmi(data)


def bmi(data):

    i=0

    print("#### BMI ####")

    while(i < len(data)):

        data[i].bmi()
       
        print("")

        i+=1


setup()

Lab7 - Find student BMI

class Student:
    def __init__(self,name,id,age,weight,height):
        self.name = name
        self.id = id
        self.age = age
        self.weight = weight
        self.height = height
    def display(self):
        print("Name : ",self.name)
        print("Weight : ",self.weight)
        print("Height : ",self.height)
     
    def bmi(self):
        bmi=self.weight/((self.height/100)*(self.height/100))
        print("Your BMI is" ,bmi)
     
def setup():
    a = Student( "Antony" , 11 , 22 , 65 , 165 )
    b = Student( "Mike" , 12 , 23 , 66 , 171 )
    c = Student( "Jacky" , 23 , 21 , 58 , 162 )
    d = Student( "Bank" , 30 , 22 , 60 , 177 )
    e = Student( "Billy" , 1 , 20 , 62 , 180 )
    f = Student( "Biccy" , 3 , 24 , 62 , 181 )
    data = [a,b,c,d,e,f]
    bmi(data)

def bmi(data):
    i=0
    print("#### BMI ####")
    while(i < len(data)):
        data[i].display()
        data[i].bmi()
        print("")
        i+=1

setup()