Monday, 16 February 2009

computer programming~~~~

import javax.swing.JOptionPane;
public class GradeGPACalculation { //main method public static void main(String[] args){ final int NUM =5; String[] sub = new String[NUM]; float[] final_mark = new float[NUM]; String[] gr = new String[NUM]; int cre =3; float GPA=0; //call method for input data input(sub, final_mark, NUM); //call method for computing grade calcGrade(gr, final_mark, NUM); //call method for computing GPA GPA = calcGPA(gr,cre, NUM); //Display output display(sub, final_mark,gr,GPA,cre,NUM); } //calculate GPA public static float calcGPA(String[] gr,int cre,int n){ float point=0; //find the total point earn for all subject // exampel: point1*credit + point2*credit +... for(int i=0; i//caculate grade public static void calcGrade(String[] gr, float[] mk, int n){ //assign grade for each subject n for(int i=0; i=80) gr[i]="A"; else if (mk[i]>=75) gr[i]="A-"; else if (mk[i]>=70) gr[i]="B+"; else if (mk[i]>=65) gr[i]="B"; else if (mk[i]>=60) gr[i]="B-"; else if (mk[i]>=55) gr[i]="C+"; else if (mk[i]>=50) gr[i]="C"; else if (mk[i]>=47) gr[i]="C-"; else if (mk[i]>=44) gr[i]="D+"; else if (mk[i]>=40) gr[i]="D"; else gr[i]="F"; } }

//read subject name and final mark public static void input(String[] sub, float[] mk, int n){ //read subject name for (int i=0; i //display subject grade and GPA public static void display(String[] sub, float[] mk,String[] gr,float GPA,int cre,int n){ //prepare the result String output = "Suject Credit Mark Grade"; for(int i=0; i

No comments:

Post a Comment