วันพฤหัสบดีที่ 5 พฤศจิกายน พ.ศ. 2558

Lab 8 - String(Version 2) [JAVA]

public class Banner {
private String word;
private String symbol;

public Banner(String word, String symbol) {
this.word = word;
this.symbol = symbol;
}

public void printWord() {
String[] A = { "A", "  #  ", " # # ", "#   #", "#####", "#   #" };
String[] C = { "C", "#####", "#    ", "#    ", "#    ", "#####" };
String[] E = { "E", "#####", "#    ", "#### ", "#    ", "#####" };
String[] blank = { " ", "  ", "  ", "  ", "  ", "  " };
String[][] character = { A, C, E, blank };
this.changesymbol(character);
char[] wordArray = this.word.toCharArray();
for (int row = 1; row <= 5; row++) {
for (int i = 0; i < this.word.length(); i++) {
for (int j = 0; j < character.length; j++) {
char checkChar = character[j][0].charAt(0);
if (wordArray[i] == checkChar) {
System.out.print(character[j][row]+" ");
}
}
}
System.out.println();
}
}

public void changesymbol(String[][] character) {
for (int i = 0; i < character.length; i++) {
for (int j = 1; j < character[i].length; j++) {
character[i][j] = character[i][j].replace("#",this.symbol);
}
}
}

public void set_symbol(String symbol) {
this.symbol = symbol;
}

public static void main(String[] args) {
Banner word = new Banner("AEC ACE ECE ACA", "#");
word.printWord();
System.out.println();
word.set_symbol("*");
word.printWord();
}
}

Lab 8 - String(Version 1) [JAVA]

public class Banner {
private String word;
private String symbol;

public Banner(String word, String symbol) {
this.word = word;
this.symbol = symbol;
}

public void printWord() {
String[] A = { "A", "  #  ", " # # ", "#   #", "#####", "#   #" };
String[] C = { "C", "#####", "#    ", "#    ", "#    ", "#####" };
String[] E = { "E", "#####", "#    ", "#### ", "#    ", "#####" };
String[] blank = { " ", "  ", "  ", "  ", "  ", "  " };
String[][] character = { A, C, E, blank };
this.changesymbol(character);
char[] wordArray = this.word.toCharArray();
for (int row = 1; row <= 5; row++) {
for (int i = 0; i < this.word.length(); i++) {
for (int j = 0; j < character.length; j++) {
char checkChar = character[j][0].charAt(0);
if (wordArray[i] == checkChar) {
System.out.print(character[j][row]+" ");
}
}
}
System.out.println();
}
}

public void changesymbol(String[][] character) {
for (int i = 0; i < character.length; i++) {
for (int j = 1; j < character[i].length; j++) {
String newSymbol = "";
char[] wordArray = character[i][j].toCharArray();
char checkSymbol = this.symbol.charAt(0);
for (int k = 0; k < character[i][j].length(); k++) {
if (wordArray[k] != checkSymbol && wordArray[k] != ' ') {
newSymbol += this.symbol;
} else {
newSymbol += wordArray[k];
}
}
character[i][j] = newSymbol;

}
}
}

public void set_symbol(String symbol) {
this.symbol = symbol;
}

public static void main(String[] args) {
Banner word = new Banner("AEC ACE ECE ACA", "#");
word.printWord();
System.out.println();
word.set_symbol("*");
word.printWord();
}
}

วันพุธที่ 4 พฤศจิกายน พ.ศ. 2558

Lab 8 - Student(Age) [JAVA]

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

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

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

public void display() {
System.out.println("Name : " + this.name);
System.out.println("ID : " + this.ID);
System.out.println("Age : " + this.age);
System.out.println("Weight : " + this.weight);
System.out.println("Height : " + this.height + "\n");
}

public static void main(String[] args) {
Student[] std = { new Student("ant", 58001, 39, 55, 165), new Student("bird", 58010, 25, 75, 170),
new Student("cat", 58011, 19, 44, 155), new Student("dog", 58100, 30, 72, 169),
new Student("eagle", 58101, 22, 70, 178), new Student("frog", 58110, 18, 100, 175) };

System.out.println("Number of students with age < 30 =" + find_numAge_lessthan30(std) + "\n \n");
System.out.println("Student Data (Sort by Age)");
insertionSort_byAge(std);
for (int i = 0; i < std.length; i++) {
System.out.println();
std[i].display();
}
}

public static int find_numAge_lessthan30(Student[] student) {
int count = 0;
for (int i = 0; i < student.length; i++) {
if (student[i].get_age() < 30) {
count += 1;
}
}
return count;
}

public static void insertionSort_byAge(Student[] student) {
for (int i = 1; i < student.length; i++) {
Student currentStudent = student[i];
int position = i;
while(position > 0 && student[position - 1].get_age() > currentStudent.get_age()) {
student[position] = student[position - 1];
position--;
}
student[position] = currentStudent;
}
}
}

Lab 8 - Student(Weight) [JAVA]

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

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

  public void display() {
    System.out.println("Name : "+this.name);
    System.out.println("ID : "+this.ID);
    System.out.println("Age : "+this.age);
    System.out.println("Weight : "+this.weight);
    System.out.println("Height : "+this.height+"\n");
  }
  public static void main(String[] args){
    Student[] std = {new Student("ant",58001,39,55,165),
           new Student("bird",58010,25,75,170),
           new Student("cat",58011,19,44,155),
           new Student("dog",58100,30,72,169),
           new Student("eagle",58101,22,70,178),
           new Student("frog",58110,18,100,175)};

    System.out.println("Number of students with weight < 50 = "+find_numWeight_lessthan50(std)+"\n");
    for(int i = 0; i < std.length; i++){
        if(std[i].get_weight() < 50){
            std[i].display();
        }
    }
  }
 
  public static int find_numWeight_lessthan50(Student[] student){
    int count = 0;
    for(int i = 0; i < student.length; i++){
        if(student[i].get_weight() < 50){
            count += 1;
        }
    }
    return count;
  }
}

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

Lab 8 - Student(BMI) [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, int weight, int height) {
    this.name = name;
    this.ID = ID;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }

  public void display() {
    System.out.println("Name : "+this.name);
    System.out.println("ID : "+this.ID);
    System.out.println("Age : "+this.age);
    System.out.println("Weight : "+this.weight);
    System.out.println("Height : "+this.height);
  }

  public float get_weight(){
    return this.weight;
  }
   
  public float get_height(){
    return this.height;
  }
  public static void main(String[] args){
    Student[] std = {new Student("ant",58001,39,55,165),
           new Student("bird",58010,25,75,170),
           new Student("cat",58011,19,44,155),
           new Student("dog",58100,30,72,169),
           new Student("eagle",58101,22,70,178),
           new Student("frog",58110,18,100,175)};
System.out.println("Number of students with BMI > 25 ="+find_numBMI_greaterthan25(std));
    int i = 0;
    while(i < std.length){
      if(calBMI(std[i]) > 25){
        System.out.println();
        std[i].display();
        System.out.println("BMI : "+String.format("%.2f",calBMI(std[i])));
      }
      i += 1;
    }
  }
 
  public static float calBMI(Student student){
    float highM = student.get_height()/100;
    float bmi = student.get_weight()/(highM*highM);
    return bmi;
  }
  public static int find_numBMI_greaterthan25(Student[] student){
    int i = 0;
    int count = 0;
    while(i < student.length){
      if(calBMI(student[i]) > 25){
        count += 1;
      }
      i += 1;
    }
    return count;
  }
}

Lab 8 - Student(Display) [JAVA]

public class Student {
  private String name;
  private int ID;
  private int age;
  private int weight;
  private int height;
 
  public Student(String name, int ID, int age, int weight, int height) {
    this.name = name;
    this.ID = ID;
    this.age = age;
    this.weight = weight;
    this.height = height;
  }

  public void display() {
    System.out.println("Name : "+this.name);
    System.out.println("ID : "+this.ID);
    System.out.println("Age : "+this.age);
    System.out.println("Weight : "+this.weight);
    System.out.println("Height : "+this.height+"\n");
  }
  public static void main(String[] args){
    Student[] std = {new Student("ant",58001,39,55,165),
           new Student("bird",58010,25,75,170),
           new Student("cat",58011,19,44,155),
           new Student("dog",58100,30,72,169),
           new Student("eagle",58101,22,70,178),
           new Student("frog",58110,18,100,175)};

    int i = 0;
    while(i < std.length){
        std[i].display();
        i = i + 1;
    }
  }
}

Lab 7 - String (Version 2)

class Banner:
    def __init__(self,word,symbol):
        self.word = word
        self.symbol = symbol
       
    def printWord(self):
        A = ["A","  #  "," # # ","#   #","#####","#   #"]
        C = ["C","#####","#    ","#    ","#    ","#####"]
        E = ["E","#####","#    ","#### ","#    ","#####"]
        blank = [" ","  ","  ","  ","  ","  "]
        char = [A,C,E,blank]
        self.changesymbol(char)
        row = 1
        while(row <= 5):
            i = 0
            while(i < len(self.word)):
                j = 0
                while(j < len(char)):
                    if(self.word[i] == char[j][0]):
                        print(char[j][row],end = " ")
                    j+=1
                i += 1
            print("")
            row += 1
           
    def changesymbol(self,character):
        i = 0
        while(i < len(character)):
            j = 1
            while(j < len(character[i])):
                character[i][j] = character[i][j].replace("#",self.symbol)
                j += 1
            i += 1

    def set_symbol(self,symbol):
        self.symbol = symbol

def setup():
    word = Banner("AEC ACE ECE ACA","#")
    word.printWord()
    print()
    word.set_symbol("*")
    word.printWord()

setup()

Lab 7 - String (Version 1)

class Banner:
    def __init__(self,word,symbol):
        self.word = word
        self.symbol = symbol
       
    def printWord(self):
        A = ["A","  #  "," # # ","#   #","#####","#   #"]
        C = ["C","#####","#    ","#    ","#    ","#####"]
        E = ["E","#####","#    ","#### ","#    ","#####"]
        blank = [" ","  ","  ","  ","  ","  "]
        char = [A,C,E,blank]
        self.changesymbol(char)
        row = 1
        while(row <= 5):
            i = 0
            while(i < len(self.word)):
                j = 0
                while(j < len(char)):
                    if(self.word[i] == char[j][0]):
                        print(char[j][row],end = " ")
                    j+=1
                i += 1
            print("")
            row += 1
           
    def changesymbol(self,character):
        i = 0
        while(i < len(character)):
            j = 1
            while(j < len(character[i])):
                k = 0
                newSymbol = ""
                while(k < len(character[i][j])):
                    if(character[i][j][k] != self.symbol and character[i][j][k] != " "):
                        newSymbol += self.symbol
                    else:
                        newSymbol += character[i][j][k]
                    k += 1
                character[i][j] = newSymbol
                j += 1
            i += 1

    def set_symbol(self,symbol):
        self.symbol = symbol

def setup():
    word = Banner("AEC ACE ECE ACA","#")
    word.printWord()
    print()
    word.set_symbol("*")
    word.printWord()

setup()

Lab 7 - Student (Weight)

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("ID :",self.ID)
        print("Age :",self.age)
        print("Weight :",self.weight)
        print("Height :",self.height)

    def get_weight(self):
        return self.weight

def setup():
    std = [Student("ant",58001,39,55,165),
           Student("bird",58010,25,75,170),
           Student("cat",58011,19,44,155),
           Student("dog",58100,30,72,169),
           Student("eagle",58101,22,70,178),
           Student("frog",58110,18,100,175)]

    print("Number of students with weight < 50 =",find_numWeight_lessthan50(std),"\n")
    i = 0
    while(i < len(std)):
        if(std[i].get_weight() < 50):
            std[i].display()
        i += 1


def find_numWeight_lessthan50(student):
    i = 0
    count = 0
    while(i < len(student)):
        if(student[i].get_weight() < 50):
            count += 1
        i += 1
    return count

setup()

Lab 7 - Student (Age)

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("ID :",self.ID)
        print("Age :",self.age)
        print("Weight :",self.weight)
        print("Height :",self.height)

    def get_age(self):
        return self.age
   
def setup():
    std = [Student("ant",58001,39,55,165),
           Student("bird",58010,25,75,170),
           Student("cat",58011,19,44,155),
           Student("dog",58100,30,72,169),
           Student("eagle",58101,22,70,178),
           Student("frog",58110,18,100,175)]

    print("Number of students with age < 30 =",find_numAge_lessthan30(std),"\n \n")
    print("Student Data (Sort by Age)")
    i = 0
    insertionSort_byAge(std)
    while(i < len(std)):
        print()
        std[i].display()
        i += 1

def find_numAge_lessthan30(student):
    i = 0
    count = 0
    while(i < len(student)):
        if(student[i].get_age() < 30):
            count += 1
        i += 1
    return count

def insertionSort_byAge(student):
    for i in range(1,len(student)):
        currentStudent = student[i]
        position = i
        while(position > 0 and student[position-1].get_age() > currentStudent.get_age()):
            student[position] = student[position-1]
            position = position-1
        student[position] = currentStudent
       

setup()

Lab 7 - 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("ID :",self.ID)
        print("Age :",self.age)
        print("Weight :",self.weight)
        print("Height :",self.height)

    def get_weight(self):
        return self.weight
   
    def get_height(self):
        return self.height

def setup():
    std = [Student("ant",58001,39,55,165),
           Student("bird",58010,25,75,170),
           Student("cat",58011,19,44,155),
           Student("dog",58100,30,72,169),
           Student("eagle",58101,22,70,178),
           Student("frog",58110,18,100,175)]
    print("Number of students with BMI > 25 =",find_numBMI_greaterthan25(std))
    i = 0
    while(i < len(std)):
        if(calBMI(std[i]) > 25):
            print()
            std[i].display()
            print("BMI : %.2f"%calBMI(std[i]))
        i += 1

def calBMI(student):
    highM = student.get_height()/100
    bmi = student.get_weight()/(highM*highM)
    return bmi

def find_numBMI_greaterthan25(student):
    i = 0
    count = 0
    while(i < len(student)):
        if(calBMI(student[i]) > 25):
            count += 1
        i += 1
    return count
setup()

Lab 7 - Student (Display)

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("ID :",self.ID)
        print("Age :",self.age)
        print("Weight :",self.weight)
        print("Height :",self.height,"\n")

def setup():
    std = [Student("ant",58001,39,55,165),
           Student("bird",58010,25,75,170),
           Student("cat",58011,19,44,155),
           Student("dog",58100,30,72,169),
           Student("eagle",58101,22,70,178),
           Student("frog",58110,18,100,175)]

    i = 0
    while(i < len(std)):
        std[i].display()
        i += 1
 
setup()

วันอาทิตย์ที่ 25 ตุลาคม พ.ศ. 2558

Lab 6 - Student Data (Age)(While Version)

def setup():
    student_name = ["ant","bird","cat","dog","eagle","frog"]
    student_id = [58001,58010,58011,58100,58101,58110]
    student_age = [39,25,19,30,22,18]
    student_weight = [55,75,44,72,70,100]
    student_height = [165,170,155,169,178,175]
   
    display(student_name,student_id,student_age,student_weight,student_height)
   
 
def display(name,ID,age,weight,height):
    print("Number of students with age < 30 =",find_numAge_lessthan30(age))
    i = 0
    insertionSort_byAge(name,ID,age,weight,height)
    while(i < len(name)):
        print("\nName :",name[i])
        print("ID :",ID[i])
        print("Age :",age[i])
        print("Weight :",weight[i])
        print("Height :",height[i])
        i += 1

def find_numAge_lessthan30(age):
    i = 0
    count = 0
    while(i < len(age)):
        if(age[i] < 30):
            count += 1
        i += 1
    return count

def insertionSort_byAge(name,ID,age,weight,height):
    i = 1
    while(i < len(age)):
        currentName = name[i]
        currentID = ID[i]
        currentAge = age[i]
        currentWeight = weight[i]
        currentHeight = height[i]

        position = i
        while(position > 0 and age[position-1] > currentAge):
            name[position] = name[position-1]
            ID[position] = ID[position-1]
            age[position] = age[position-1]
            weight[position] = weight[position-1]
            height[position] = height[position-1]
            position = position-1
           
        name[position] = currentName
        ID[position] = currentID
        age[position] = currentAge
        weight[position] = currentWeight
        height[position] = currentHeight
        i += 1

setup()

Lab 6 - Transpose Matrix (While Version)

def setup():
    a = [1,1,2]
    b = [5,5,5]
    c = [9,1,1]
    matrix = [a,b,c]
    display(matrix)
    print()
    display(transpose(matrix))
def display(matrix):
    i = 0
    while(i < len(matrix)):
        j = 0
        while(j < len(matrix[i])):
            print(matrix[i][j],end = ' ')
            j += 1
        print()
        i += 1

def transpose(matrix):
    i = 0
    while(i < len(matrix)):
        j = i+1
        while(j < len(matrix[i])):
            temp = matrix[i][j]
            matrix[i][j] = matrix[j][i]
            matrix[j][i] = temp
            j += 1
        i += 1
    return matrix

setup()

Lab 6 - Transpose Matrix

def setup():
    a = [1,1,2]
    b = [5,5,5]
    c = [9,1,1]
    matrix = [a,b,c]
    display(matrix)
    print()
    display(transpose(matrix))
def display(matrix):
    i = 0
    while(i < len(matrix)):
        j = 0
        while(j < len(matrix[i])):
            print(matrix[i][j],end = ' ')
            j += 1
        print()
        i += 1

def transpose(matrix):
    for i in range (0,len(matrix)):
        for j in range (i+1,len(matrix[i])):
            temp = matrix[i][j]
            matrix[i][j] = matrix[j][i]
            matrix[j][i] = temp
    return matrix

setup()

Lab 6 - Matrix

def setup():
    matrix1 = [[15,50],[4,16]]
    matrix2 = [[15,10],[10,12]]
    print("Matrix One")
    display(matrix1)
    print("\nMatrix Two")
    display(matrix2)
    print("\nAdd Two Matrices")
    display(addMatrix(matrix1,matrix2))
    print("\nSubtract Two Matrices")
    display(subtractMatrix(matrix1,matrix2))
    print("\nMultiply Two Matrices")
    display(multiplyMatrix(matrix1,matrix2))

   
def display(matrix):
    i = 0
    while(i < len(matrix)):
        j = 0
        while(j < len(matrix[i])):
            print(matrix[i][j],end = ' ')
            j += 1
        print()
        i += 1

def addMatrix(matrix1,matrix2):
    answer = [[0,0],[0,0]]
    i = 0
    while(i < len(matrix1)):
        j = 0
        while(j < len(matrix1[i])):
            answer[i][j] = matrix1[i][j]+matrix2[i][j]
            j += 1
        i += 1
    return answer

def subtractMatrix(matrix1,matrix2):
    answer = [[0,0],[0,0]]
    i = 0
    while(i < len(matrix1)):
        j = 0
        while(j < len(matrix1[i])):
            answer[i][j] = matrix1[i][j]-matrix2[i][j]
            j += 1
        i += 1
    return answer

def multiplyMatrix(matrix1,matrix2):
    answer = [[0,0],[0,0]]
    i = 0
    while(i < len(matrix1)):
        j = 0
        k = 0
        while(j < len(matrix1[i])):
            answer[i][j] = (matrix1[i][k]*matrix2[k][j])+(matrix1[i][k+1]*matrix2[k+1][j])
            j += 1
        i += 1
    return answer

setup()

Lab 6 - Chair in Building

def setup():
    floor1 = [20,15,15,25,30,20]
    floor2 = [20,40,35,20,35,35]
    floor3 = [25,40,10,40,30,25]
    floor4 = [20,15,15,40,15,15]
    building = [floor1,floor2,floor3,floor4]

    print("Total number of chairs =",sumChair(building))
    print("\nThe floor with maximum number of chairs :\n - floor "+str(findFloor_maxChair(building)))
    print("\nThe Room with maximum number of chairs : "+findRoom_maxChair(building))

def sumChair(building):
    i = 0
    sum = 0
    while(i < len(building)):
        j = 0
        while(j < len(building[i])):
            sum += building[i][j]
            j += 1
        i += 1
    return sum

def findFloor_maxChair(building):
    i = 0
    floor = 0
    sumChair = 0
    totalChair = 0
    while(i < len(building)):
        j = 0
        while(j < len(building[i])):
            sumChair += building[i][j]
            j += 1
        if(totalChair < sumChair):
            totalChair = sumChair
            floor = i
        sumChair = 0
        i += 1
    return floor+1

def findRoom_maxChair(building):
    floor = 0
    maxChair = 0
    maxChair_room = ""
    while(floor < len(building)):
        room = 0
        while(room < len(building[floor])):
            if(maxChair < building[floor][room]):
                maxChair = building[floor][room]
            room += 1
        floor += 1
       
    i = 0
    while(i <  len(building)):
        j = 0
        while(j < len(building[i])):
            if(maxChair == building[i][j]):
                maxChair_room += "\n - Room "+str(j+1)+" Floor "+str(i+1)
            j += 1
        i += 1
    return maxChair_room
setup()

วันศุกร์ที่ 23 ตุลาคม พ.ศ. 2558

Lab 6 - Student Data (Weight)

def setup():
    student_name = ["ant","bird","cat","dog","eagle","frog"]
    student_id = [58001,58010,58011,58100,58101,58110]
    student_age = [39,25,19,30,22,18]
    student_weight = [55,75,44,72,70,100]
    student_height = [165,170,155,169,178,175]
   
    display(student_name,student_id,student_age,student_weight,student_height)
   
 
def display(name,ID,age,weight,height):
    print("Number of students with weight < 50 =",find_numWeight_lessthan50(weight))
    i = 0
    while(i < len(name)):
        if(weight[i] < 50):
            print("\nName :",name[i])
            print("ID :",ID[i])
            print("Age :",age[i])
            print("Weight :",weight[i])
            print("Height :",height[i])
         
        i += 1

def find_numWeight_lessthan50(weight):
    i = 0
    count = 0
    while(i < len(weight)):
        if(weight[i] < 50):
            count += 1
        i += 1
    return count


setup()

Lab 6 - Student Data (Age)

def setup():
    student_name = ["ant","bird","cat","dog","eagle","frog"]
    student_id = [58001,58010,58011,58100,58101,58110]
    student_age = [39,25,19,30,22,18]
    student_weight = [55,75,44,72,70,100]
    student_height = [165,170,155,169,178,175]
   
    display(student_name,student_id,student_age,student_weight,student_height)
   
 
def display(name,ID,age,weight,height):
    print("Number of students with age < 30 =",find_numAge_lessthan30(age))
    i = 0
    insertionSort_byAge(name,ID,age,weight,height)
    while(i < len(name)):
        print("\nName :",name[i])
        print("ID :",ID[i])
        print("Age :",age[i])
        print("Weight :",weight[i])
        print("Height :",height[i])
        i += 1

def find_numAge_lessthan30(age):
    i = 0
    count = 0
    while(i < len(age)):
        if(age[i] < 30):
            count += 1
        i += 1
    return count

def insertionSort_byAge(name,ID,age,weight,height):
    for i in range(1,len(age)):
        currentName = name[i]
        currentID = ID[i]
        currentAge = age[i]
        currentWeight = weight[i]
        currentHeight = height[i]

        position = i
        while(position > 0 and age[position-1] > currentAge):
            name[position] = name[position-1]
            ID[position] = ID[position-1]
            age[position] = age[position-1]
            weight[position] = weight[position-1]
            height[position] = height[position-1]
            position = position-1
           
        name[position] = currentName
        ID[position] = currentID
        age[position] = currentAge
        weight[position] = currentWeight
        height[position] = currentHeight


setup()

Lab 6 - Student Data (BMI)

def setup():
    student_name = ["ant","bird","cat","dog","eagle","frog"]
    student_id = [58001,58010,58011,58100,58101,58110]
    student_age = [39,25,19,30,22,18]
    student_weight = [55,75,44,72,70,100]
    student_height = [165,170,155,169,178,175]
   
    display(student_name,student_id,student_weight,student_height)
   
 
def display(name,ID,weight,height):
    print("Number of students with BMI > 25 =",find_numBMI_greaterthan25(weight,height))
    i = 0
    while(i < len(name)):
        if(calBMI(weight[i],height[i]) > 25):
            print("\nName :",name[i])
            print("ID :",ID[i])
            print("Weight :",weight[i])
            print("Height :",height[i])
            print("BMI : %.2f"%calBMI(weight[i],height[i]))
        i += 1

def calBMI(weight,height):
    highM = height/100
    bmi = weight/(highM*highM)
    return bmi

def find_numBMI_greaterthan25(weight,height):
    i = 0
    count = 0
    while(i < len(weight)):
        if(calBMI(weight[i],height[i]) > 25):
            count += 1
        i += 1
    return count


setup()

Lab 6 - Student Data (Display)

def setup():
   student_name = ["ant","bird","cat","dog","eagle","frog"]
   student_id = [58001,58010,58011,58100,58101,58110]
   student_age = [39,25,19,30,22,18]
   student_weight = [55,75,44,72,70,100]
   student_height = [165,170,155,169,178,175]
 
   display(student_name,student_id,student_age,student_weight,student_height)
 
def display(name,ID,age,weight,height):
   i = 0
   while(i < len(name)):
      print("Name :",name[i])
      print("ID :",ID[i])
      print("Age :",age[i])
      print("Weight :",weight[i])
      print("Height :",height[i],"\n")
      i += 1
 
setup()

Lab 5 - Array

def setup():
    n = [ 16,48,64,-15,64,64,-69,30,-13,29]
    showIndex(n)
    print("\nMaximum =",find_maxNum(n))
    print("First Index Maximum =",find_firstMaxNum(n))
    print("Last Index Maximum =",find_lastMaxNum(n))
    print("Sum of Value =",sumValue(n))
    print("Sum of Positive Value =",sumPositiveValue(n))
    print("Count Number of Positive Value =",countPositiveNumber(n))
    print("Average of Value =",averageValue(n),"\n\n")
    showValue_afterChange(n)

   
def showIndex(n):
    i = 0
    while(i < len(n)):
        print("Index",i,"=",n[i])
        i += 1
   
def find_maxNum(n):
    i = 0
    maxNum = 0
    while(i < len(n)):
        if(n[i]> maxNum):
            maxNum = n[i]
        i += 1
    return maxNum

def find_firstMaxNum(n):
    i = 0
    maxNum = 0
    indexMax = 0
    while(i < len(n)):
        if(n[i]> maxNum):
            maxNum = n[i]
            indexMax = i
        i += 1
    return indexMax

def find_lastMaxNum(n):
    i = 0
    maxNum = 0
    indexMax = 0
    while(i < len(n)):
        if(n[i]> maxNum):
            maxNum = n[i]
        elif(n[i]== maxNum):
            indexMax = i
        i += 1
    return indexMax

def sumValue(n):
    i = 0
    sum_value = 0
    while(i < len(n)):
        sum_value += n[i]
        i += 1
    return sum_value

def sumPositiveValue(n):
    i = 0
    sum_positiveValue = 0
    while(i < len(n)):
        if(n[i] >= 0):
            sum_positiveValue += n[i]
        i += 1
    return sum_positiveValue

def countPositiveNumber(n):
    i = 0
    count_positive = 0
    while(i < len(n)):
        if(n[i] >= 0):
            count_positive += 1
        i += 1
    return count_positive

def averageValue(n):
    i = 0
    sum_value = 0
    while(i < len(n)):
        sum_value += n[i]
        i += 1
    average = sum_value/len(n)
    return average

def showValue_afterChange(n):
    change = -50
    i = 0
    if(change >= 0):
        print("Increase =",change)
    else:
        print("Decrease =",change)
    while(i < len(n)):
        n[i] += change
        print("Index",i,"=",n[i])
        i += 1

   
setup()

Lab 5 - Base 10 to Base 2

def setup():
    print(changeBase_ten_to_two(8))
    print(changeBase_ten_to_two(9))
    print(changeBase_ten_to_two(17))
   
def changeBase_ten_to_two(baseTen):
    baseTwo = ""
    while(baseTen > 0):
        baseTwo = str(baseTen%2)+baseTwo
        baseTen = int(baseTen/2)
    return baseTwo
       
setup()

วันอาทิตย์ที่ 18 ตุลาคม พ.ศ. 2558

Lab 5 - String

def setup():
   print(myCount("peejalovelove","e"))
   print(myFind("Thailand", "i"))
   print(myReplace("Thailand", "Thai", "Eng"))
   print(myStrip("The Land of Smile"))
   assert(startWith("peejalovelove","pee")) == True
   assert(endWith("peejalovelove","ja")) == False
 
def myCount(fullword,char):
   count = 0
   i = 0
   while(i < len(fullword)):
      if(fullword[i] == char):
         count += 1
      i += 1
   return count

def myFind(fullword,char):
   index = 0
   i = 0
   while(i < len(fullword)):
      if(fullword[i] == char):
         index = i
      i += 1
   return index

def myReplace(fullword,oldword,replace):
   newWord = ""
   i = 0
   while(i < len(fullword)):
      if(fullword[i] != oldword[0]):
         newWord += fullword[i]
         i += 1
      else:
         num = 0
         while(num < len(oldword) and oldword[num] == fullword[i+num]):
            num += 1
         if(num == len(oldword)):
            newWord += replace
            i += len(oldword)
   return newWord

def myStrip(word):
   newWord = ""
   i = 0
   while(i < len(word)):
      if(word[i] != " "):
         newWord += word[i]
      i += 1
   return newWord

def startWith(fullword,startword):
   wordCheck = list(fullword)
   startCheck = list(startword)
   i = 0
   while(i < len(startCheck)):
      if(startCheck[i] != wordCheck[i]):
         return False
      i += 1
   return True

def endWith(fullword,endword):
   wordCheck = list(fullword)
   endCheck = list(endword)
   i = 0
   while(i < len(endCheck)):
      if(endCheck[i+(len(endCheck)-1)] != wordCheck[i+(len(wordCheck)-1)]):
         return False
      i += 1
   return True

setup()

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

Lab4x - Summation of Prime Number

def setup():
  print("Sum of Prime Number\n")
  sum_prime(0,20)
  sum_prime(0,100)

def sum_prime(minNumber,maxNumber):
   print(minNumber,"-",maxNumber)
   sumPrime = 0
   while (minNumber <= maxNumber):
      if (prime(minNumber)):
         sumPrime += minNumber
      minNumber += 1
   print("Sum = ",sumPrime)

def prime(value):
   num = 2
   while (num <= value):
      if (value%num == 0):
         if (value == num):
            return True
         else:
            return False
      num += 1
   return False
 
setup()

Lab4x - Summation of Integers

def setup():
   print("Sum of Integers\n")
   sumIntegers(1,5)
   sumIntegers(1,20)
 
def sumIntegers(minNumber,maxNumber):
   print(minNumber," + ",(minNumber+1)," + ... + ",maxNumber)
   sumIntegers = 0
   while (minNumber <= maxNumber):
      sumIntegers = sumIntegers + minNumber
      minNumber = minNumber+1
   print("Sum = ",sumIntegers)
 
setup()

Lab4x - Service Charge

def setup():
    packageType = 2
    serviceType = 3
    weight = 16
    print("Expressimo Delivery Service")
    charge(packageType, serviceType, weight)

def charge(package_type, service_type, weight):
    cost = 0
    if (package_type == 1):
        print("Package : LETTER");
        if (service_type == 1):
            print("Service : Next day Priority")
            if (weight <= 8):
                cost = 12
            else:
                cost = 0

        elif (service_type == 2):
            print("Service : Next day Standard")
            if (weight <= 8):
                cost = 10.5
            else:
                cost = 0

        elif (service_type == 3):
            print("Service : No Service")
        else:
            print("Service : ERROR")

        print("Weight : ",weight," Oz")
    elif (package_type == 2):
        print("Package : BOX")
        if (service_type == 1):
            print("Service : Next day Priority")
            if (weight <= 1):
                cost = 15.75
            else:
                cost = cal_service1(weight)

        elif (service_type == 2):
            print("Service : Next day Standard")
            if (weight <= 1):
                cost = 13.75
            else:
                cost = cal_service2(weight)

        elif (service_type == 3):
            print("Service : Two-days")
            if (weight <= 1):
                cost = 7.00
            else:
                cost = cal_service3(weight)

        else:
            print("Service : ERROR")

        print("Weight :",weight,"Pound")

    else:
        print("Package : ERROR")

    print("Charge : $",cost)

def cal_service1(weight):
  firstCharge = 15.75
  priority_charge = firstCharge + ((weight-1)*1.25)
  return priority_charge

def cal_service2(weight):
  firstCharge = 13.75;
  standard_charge = firstCharge + ((weight-1)*1)
  return standard_charge

def cal_service3(weight):
  firstCharge = 7.00
  twodays_charge = firstCharge + ((weight-1)*0.5)
  return twodays_charge

setup()

Lab4x - Loan

def setup():
    loanAmount = 5000
    interestPercent = 12
    loanTerm = 12

    loan(loanAmount,interestPercent,loanTerm);

def loan(loanAmount,interestPercent,loanTerm):
    print("Payment No.   Principal    Interest    Balance       Total Interest")
    showValue(loanAmount,interestPercent,loanTerm)

def showValue(loanAmount,interestPercent,loanTerm):
    interestRate = interestPercent/100
    effectiveInterest = interestRate/12
    monthlyPayment = loanAmount*(effectiveInterest/(1-pow(1+effectiveInterest, -loanTerm)))
   
    interest = 0
    totalInterest = 0
    principal = 0
    balance = loanAmount
    term = 1
    while (term <= loanTerm):
        interest = balance * effectiveInterest;
        principal = monthlyPayment-interest;
        totalInterest += interest;
        balance -= principal;
        if (balance <= 0):
            balance = 0

        print(term,"           ","$%.2f"%principal,"    ","%.2f"%interest,"    ","$%.2f"%balance,"    ","$%.2f"%totalInterest)
        term += 1

setup()

Lab4x - Power of Ten

def setup():
   print("Power of 10\n")
   power_of_ten(9)
   power_of_ten(100)
 
def power_of_ten(power):
   print("Power =",power)
   if (power == 6):
      print("'Million'")
   elif (power == 9):
      print("'Billion'")
   elif (power == 12):
      print("'Trillion'")
   elif (power == 15):
      print("'Quadrillion'")
   elif (power == 18):
      print("'Quintillion'")
   elif (power == 21):
      print("'Setillion'")
   elif (power == 30):
      print("'Nonillion'")
   elif (power == 100):
      print("'Googol'")
   else:
      print("'Error'")
setup()

Lab4x - Multiplication Table

def setup():
    multi_table(9)

def multi_table(number):
    minMultiplier = 1
    maxMultiplier = 12
    while (minMultiplier <= maxMultiplier):
        answer = number*minMultiplier
        print(number," x ",minMultiplier," = ",answer)
        minMultiplier += 1

setup()

Lab4x - Leafyear

def setup():
   print("Leap Year?\n")
   leapyear(1796)
   leapyear(2000)
   leapyear(1800)
   leapyear(2015)

def leapyear(year):
   if((year%4 == 0 and year%100 != 0) or (year%4 == 0 and year%100 == 0 and year%400 == 0)):
      print("'",year,"' is a leap year.")
   else:
      print("'",year,"' isn't a leap year.")
 
setup()

Lab4x - Grade

def setup():
   cal_grade(99)

def cal_grade( score):
   print("Score = ",score)
   if (score <= 100 and score >= 80):
      print("Grade A")
   elif (score <= 79 and score >= 70):
      print("Grade B")
   elif (score <= 69 and score >= 60):
      print("Grade C")
   elif (score <= 59 and score >= 50):
      print("Grade D")
   elif (score < 50):
      print("Grade F")
      print("See you again next year.")
     
setup()

Lab4x - Circle

def setup():
    rad = 15
    print("Radius =",rad)
    print("Diameter =",cal_dia(rad))
    print("Area =",cal_area(rad))
    print("Circumference =",cal_cir(rad))

def cal_cir(rad):
    cir = 2*3.14*rad
    return cir

def cal_area(rad):
    area = 3.14*rad*rad
    return area

def cal_dia(rad):
    dia = rad*2
    return dia

setup()

Lab4x - BMI

def setup():
   print("BMI =",cal_BMI(173,60))

def cal_BMI(high,weight):
   print("Weight =",weight,"kg")
   print("Height =",high,"cm")
   highM = high/100
   BMI = weight/(highM*highM)
   return BMI
 
setup()

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

Lab4 - balloons



float x =25;
int y = 400;
int num = 8;

void setup() {
  size(750, 400);
}

void draw() {
  background(255);
  int count = 0;
  int space = 0;

  while (count < num) {
    draw_balloon(x+space, y, 50, 50);
    count += 1;
    space += 50;
  }

  y -= 4;
  if (y == -100) {
    y = 400;
    x = random(25, width-(count*50-25));
  }
}

void draw_balloon(float x, int y, int balloonSize, int string) {
  fill(#FF0000);
  ellipse(x, y, balloonSize, balloonSize);
  line(x, y+balloonSize/2, x, (y+balloonSize/2)+string);
}

void mousePressed() {
  if (mouseButton == LEFT) {
    num +=1;
    if (num>15) {
      num = 15;
    }
  }
  if (mouseButton == RIGHT) {
    num -=1;
    if (num < 1) {
      num = 1;
    }
  }
}

Lab4 - Birds



int wingFly;
int x= 30;
int birdSize = 50;
void setup() {
  size(700, 500);
}

void draw() {
  background(#AAFFFF);
  int num = 0;
  int count = 7;
  int space = 0;
  wingFly = mouseY;
  if (mouseY > height/2) {
    if (frameCount%40 > 20) {
      wingFly += birdSize/3;
    } else {
      wingFly -= birdSize/3;
    }
  } else if (mouseY < height/2) {
    if (frameCount%20 > 10) {
      wingFly += birdSize/3;
    } else {
      wingFly -= birdSize/3;
    }
  }
  while (num < count) {
    flybird(mouseX+space, mouseY, birdSize);
    num++;
    if (num%2 == 0) {
      space += num*80;
    } else if (num%2 != 0) {
      space -= num*80;
    }
  }
}

void flybird(int x, int y, int birdSize) {
  strokeWeight(3);
  fill(#FF00FF);
  ellipse(x, y, birdSize, birdSize);
  fill(0);
  ellipse(x-(birdSize/5), y, birdSize/4, birdSize/3);
  ellipse(x+(birdSize/5), y, birdSize/4, birdSize/3);
  fill(255);
  ellipse(x-(birdSize/5), y, birdSize/6, birdSize/5);
  ellipse(x+(birdSize/5), y, birdSize/6, birdSize/5);
  fill(#FFFF00);
  triangle(x-(birdSize/4), y+(birdSize/4), x+(birdSize/4), y+(birdSize/4), x, y+birdSize/1.5);

  line(x-(birdSize/2), y, x-birdSize, wingFly);
  line(x+(birdSize/2), y, x+birdSize, wingFly);
}

Lab4 - Multiplication Table



void setup() {
  size(100, 250);
  background(0);
  multi_table(8);
}

void multi_table(int number) {
  int minMultiplier = 1;
  int maxMultiplier = 12;
  int space = 20;
  while (minMultiplier <= maxMultiplier) {
    int answer = number*minMultiplier;
    text(number+" x "+minMultiplier+" = "+answer, width/6, space);
    minMultiplier += 1;
    space += 20;
  }
}

Lab4 - Summation of Prime Number



void setup() {
  size(250, 150);
  background(50);
  int minNumber = 0;
  int maxNumber = 20;
  int sum = 0;

  int space = 30;
  textAlign(CENTER);
  text("Sum of Prime Number", width/2, height/2-space);
  text(minNumber+" - "+maxNumber, width/2, height/2);
  while (minNumber <= maxNumber) {
    if (prime(minNumber)) {
      sum += minNumber;
    }
    minNumber++;
  }
  text("Sum = "+sum, width/2, height/2+space);
}
boolean prime(int value) {
  int num = 2;
  while (num <= value) {
    if (value%num == 0) {
      if (value == num) {
        return true;
      } else {
        return false;
      }
    }
    num++;
  }
  return false;
}

Lab4 - Summation of Integers



void setup() {
  int minNumber = 1;
  int maxNumber = 5;
  int sum = 0;

  size(200, 150);
  background(255);
  int space = 30;
  textAlign(CENTER);
  fill(0);
  text("Sum of Integers", width/2, height/2-space);
  text(minNumber+" + "+(minNumber+1)+" + ... + "+maxNumber, width/2+3, height/2);

  while (minNumber <= maxNumber) {
    sum += minNumber;
    minNumber +=1;
  }

  text("Sum = "+sum, width/2, height/2+space);
}

Lab4 - Loan



void setup() {
  size(450, 270);
  background(0);
  float loanAmount = 5000;
  float interestPercent = 12;
  int loanTerm = 12;

  loan(loanAmount, interestPercent, loanTerm);
}

void loan(float loanAmount, float interestPercent, int loanTerm) {
  float interestRate = interestPercent/100;
  float effectiveInterest = interestRate/12;
  float monthlyPayment = loanAmount*(effectiveInterest/(1-pow(1+effectiveInterest, -loanTerm)));
  head(30, 20);

  float interest = 0;
  float totalInterest = 0;
  float principal = 0;
  float balance = loanAmount;
  int term = 1;
  while (term <= loanTerm) {
    interest = balance * effectiveInterest;
    principal = monthlyPayment-interest;
    totalInterest += interest;
    balance -= principal;
    if (balance <= 0) {
      balance = 0;
    }
    showValue(term, balance, principal, interest, totalInterest, 30, 20*(1+term));
    term++;
  }
}

void showValue(int term, float balance, float principal, float interest, float totalInterest, int x, int y) {
  int space = 80;
  fill(#FFFF00);
  text(term, x, y);
  text("$"+nf(principal, 1, 2), x+space, y);
  text("$"+nf(interest, 1, 2), x+space*2, y);
  text("$"+nf(balance, 1, 2), x+space*3, y);  text("$"+nf(totalInterest, 1, 2), x+space*4, y);
}

void head(int x, int y) {
  int space = 80;
  fill(#FF0000);
  text("Payment No.", x, y);
  text("Principal", x+space, y);
  text("Interest", x+space*2, y);
  text("Balance", x+space*3, y);  text("Total Interest", x+space*4, y);
}

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

Lab3-Battery(Interactive)

int volumeposY = 110;
int volumeHeight = 380;
int batt_usage;
int posY_change;
int volumeColor = #008B00;
int update = 0;

void setup() {
  size(400, 600);
}

void draw() {
  int batteryposX = 100, batteryposY = 100;
  frameRate(50);
  background(0);

Lab3-Delivery Charge



int space = 50;
void setup() {
  size(650, 300);
  background(#DDFFFF);
  int x =50, y =50;

  int packageType = 2;
  int serviceType = 3;
  float weight = 16;

  fill(0);
  textSize(40);
  text("Expressimo Delivery Service", x, y);
  charge(x+space, y+space, packageType, serviceType, weight);
}

void charge(int x, int y, int package_type, int service_type, float weight) {
  float cost =0;
  fill(#FF0000);
  textSize(30);
  if (package_type == 1) {
    text("Package : LETTER", x, y);
    if (service_type == 1) {
      text("Service : Next day Priority", x, y+space);
      if (weight <= 8) {
        cost = 12;
      } else {
        cost = 0;
      }
    } else if (service_type == 2) {
      text("Service : Next day Standard", x, y+space);
      if (weight <= 8) {
        cost = 10.5;
      } else {
        cost = 0;
      }
    } else if (service_type == 3) {
      text("Service : No Service", x, y+space);
    } else {
      text("Service : ERROR", x, y+space);
    }
    text("Weight : "+weight+" Oz", x, y+space*2);
  } else if (package_type == 2) {
    text("Package : BOX", x, y);
    if (service_type == 1) {
      text("Service : Next day Priority", x, y+space);
      if (weight <= 1) {
        cost = 15.75;
      } else {
        cost = cal_service1(weight);
      }
    } else if (service_type == 2) {
      text("Service : Next day Standard", x, y+space);
      if (weight <= 1) {
        cost = 13.75;
      } else  {
        cost = cal_service2(weight);
      }
    } else if (service_type == 3) {
      text("Service : Two-days", x, y+space);
      if (weight <= 1) {
        cost = 7.00;
      } else  {
        cost = cal_service3(weight);
      }
    } else {
      text("Service : ERROR", x, y+space);
    }
    text("Weight : "+weight+" Pound", x, y+space*2);
  } else {
    text("Package : ERROR", x, y);
  }
  text("Charge : $"+cost, x, y+space*3);
}
float cal_service1(float weight) {
  float priority_charge;
  float firstCharge = 15.75;
  priority_charge = firstCharge + ((weight-1)*1.25);
  return priority_charge;
}

float cal_service2(float weight) {
  float standard_charge;
  float firstCharge = 13.75;
  standard_charge = firstCharge + ((weight-1)*1);
  return standard_charge;
}

float cal_service3(float weight) {
  float twodays_charge;
  float firstCharge = 7.00;
  twodays_charge = firstCharge + ((weight-1)*0.5);
  return twodays_charge;
}

Lab3-Leap Year



void setup() {
  int x = 50, y = 50;
  int space = 50;
  background(#AAFF88);
  size(500, 300);
  textSize(40);
  fill(#FF0000);
  text("Leap Year?", x, y);
  leapyear(x+space, y+space, 1796);
  leapyear(x+space, y+space*2, 2000);
  leapyear(x+space, y+space*3, 1800);
  leapyear(x+space, y+space*4, 2015);
}

void leapyear(int x, int y, int year) {
  fill(#008D00);
  textSize(30);
  if (is_leapYear(year)) {
    text("'"+year+"' is a leap year.", x, y);
  } else {
    text("'"+year+"' is not a leap year.", x, y);
  }
}

boolean is_leapYear(int year) {
   boolean result = false;
   if((year%4 == 0 && year%100 != 0) || (year%4 == 0 && year%100 == 0 && year%400 == 0)){
   result = true;
   }else{
   result = false;
   }
   return result;
}

Lab3-Power of 10



int space = 70;
void setup() {
  background(#2222FF);
  size(400, 250);

  int x = width/2, y = 70;
  textAlign(CENTER);
  textSize(60);
  fill(255);
  text("Power of 10", x, y);
  power_of_ten(x, y+space, 9);
}
void power_of_ten(int x, int y, int power) {
  textAlign(CENTER);
  textSize(40);
  fill(0);
  text("10^"+power, x, y);
  if (power == 6) {
    text("'Million'", x, y+space);
  } else if (power == 9) {
    text("'Billion'", x, y+space);
  } else if (power == 12) {
    text("'Trillion'", x, y+space);
  } else if (power == 15) {
    text("'Quadrillion'", x, y+space);
  } else if (power == 18) {
    text("'Quintillion'", x, y+space);
  } else if (power == 21) {
    text("'Sextillion'", x, y+space);
  } else if (power == 30) {
    text("'Nonillion'", x, y+space);
  } else if (power == 100) {
    text("'Googol'", x, y+space);
  }
}

Lab3-Grade



void setup() {
  size(400, 200);
  int x = width/2, y = 70;
  int space = 80;

  int score = 99;
  background(#0088CC);
  fill(255);
  textAlign(CENTER);
  textSize(50);
  text("Score = "+score, x, y);
  grade(x, y+space, score);
}

void grade(int x, int y, int score) {

   if (score <= 100 && score >= 80) {
    text("Grade A", x, y);
  } else if (score <= 79 && score >= 70) {
    text("Grade B", x, y);
  } else if (score <= 69 && score >= 60) {
    text("Grade C", x, y);
  } else if (score <= 59 && score >= 50) {
    text("Grade D", x, y);
  } else if (score < 50) {
    text("Grade F", x, y);
    textSize(15);
    text("See you again next year.", x, y+20);
  }
}

Lab3-SPYAIR(Interactive)

float spin = 0;
float speed = 0;
int textposX = 360;
int R = 255, G = 255, B = 255;
int x_axis = -2;
void setup() {
  size(700, 400);
}