In this program i want to enter 2 value one for GRADE ( A+ B C ....) another for Credit Hours. And calculate the GPA.
this entrey for 5 Subject
the problem here when i enter the first subject directly calculate the GPA for one subject
class GPA{
public static void main(
String args[]){
double sum=0;
int crd=0,i;
int m=3;
for(i=0;i<m;i++){
String g=(args[0]);
int c=Integer.parseInt(args[1]);
if(g.equals("A+")){
sum=sum+(4*c);
crd=crd+c;}
else if(g.equals("A")){
sum=sum+(3.75*c);
crd=crd+c;}
else if(g.equals("B+")){
sum=sum+(3.5*c);
crd=crd+c;}
else if(g.equals("B")){
sum=sum+(3*c);
crd=crd+c;}
else if(g.equals("C+")){
sum=sum+(2.5*c);
crd=crd+c;}
else if(g.equals("C")){
sum=sum+(2*c);
crd=crd+c;}
else if(g.equals("D+")){
sum=sum+(1.5*c);
crd=crd+c;}
else if(g.equals("D")){
sum=sum+(1*c);
crd=crd+c;}
else if(g.equals("F")){
sum=sum+(0*c);
crd=crd+c;}
else
System.out.println("Chek Your Grade");
}
System.out.println("Your GPA is "+(sum/crd));
}
}