When I pass certain float value to compare with my conditional statement it always executes else part.
There are some variables with values:
float total = 74.67 ;
String grade = "", point = "";
And with this values I want to do this:
if(total>=80){
grade = "A+";
point = "4.00";
}else if(total<=79 && total>=75){
grade = "A";
point = "3.75";
}else if(total>=70 && total<=74) {
grade = "A-";
point = "3.50";
}else if(total<=65 && total>=69){
grade = "B+";
point = "3.25";
}else if(total<=64 && total>=60){
grade = "B";
point = "3.00";
}else if (total<=59 && total>=55){
grade = "B-";
point = "2.75";
}else if (total<=54 && total>=50){
grade = "C+";
point = "2.50";
}else if(total<=49 && total>=45){
grade = "C";
point = "2.25";
}else if (total<=44 && total>=40){
grade = "D";
point = "2.00";
}else {
grade = "F";
point = "0.00";
}
but it always shows grade = "F" and point = "0.00".
if I write this,
if(total>=70 && total<=74) {
grade = "A-";
point = "3.50";
}
it shows grade ="" and point ="".
the value of total is showing nicely but there are problem with grade and point. can anyone tell me what is the problem?
Aucun commentaire:
Enregistrer un commentaire