0

Why it is going into else block

Why this program is going into else block even when I entered marks grater tham 33 all the time Code : https://code.sololearn.com/cMi8wnlcpzFu/?ref=app

9th Jul 2021, 6:39 AM
ᴀʀᴜꜱʜBooSΓ.java
ᴀʀᴜꜱʜBooSΓ.java - avatar
1 Réponse
+ 3
Bcoz of totalGrade, try printing value of totalGrade and you will understand. Your condition says if totalGrade > 40 but each time it evaluates to 0, hence, condition false and goes into else block. Additionally, you don't have to check marks of every subject if you are checking totalGrade. If you have 33 marks in all, it won't go above 33.0% So no need of extra conditions. Just write like if(totalGrade > 40).
9th Jul 2021, 6:49 AM
Alaska
Alaska - avatar