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

calculate grade


void setup(){
 size(200,100);
 background(0);

int score = 79 ;
 char grade ;
 if (score >= 80){ //score is greater than or equal to 80
 grade = 'A' ; //show "GRADE A"
 }else if((score < 80)&&(score >= 70)){ //score is less than 80 and greater than or equal to 70
 grade = 'B' ; //show "GRADE B"
 }else if((score < 70)&&(score >= 60)){ //score is less than 70 and greater than or equal to 60
 grade = 'C' ; //show "GRADE C"
 }else if((score < 60)&&(score >= 50)){ //score is less than 60 and greater than or equal to 50
 grade = 'D' ; //show "GRADE D"
 }else{ //score is less than 50
 grade = 'F' ; //show "GRADE F"
 }
 println("GRADE "+grade); fill(255,0,10); text("GRADE "+grade,70,50);
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น