if(g1=="O" && c1==4)
v1 = 40;
else if(g1=="A+" && c1==4)
v1 = 36;
else if(g1=="A" && c1==4)
v1 = 32;
else if(g1=="B+" && c1==4)
v1 = 28;
else if(g1=="B" && c1==4)
v1 = 24;
else if(g1=="O" && c1==3)
v1 = 30;
else if(g1=="A+" && c1==3)
v1 = 27;
else if(g1=="A" && c1==3)
v1 = 24;
else if(g1=="B+" && c1==3)
v1 = 21;
else if(g1=="B" && c1==3)
v1 = 18;
I am writing a CGPA calculating code in Java. Like this if...else block, 5 others exist in my code of the same kind!!! But variable names get changed in every block. I have initialized the variable v1, v2, etc... to 0, but still I couldn't update the values of v's in each block with respect to the grade g and credits c.
For example, if g1 is "O" and c1 is 3, v1 should be 30. But I am getting v1 as 0 when I introduced print statements at the end of each if...else block!!!!
The output I receive every time I run this code is below:

Aucun commentaire:
Enregistrer un commentaire