lundi 30 janvier 2017

Alternate to If...else-if

What is best way to reduce the line of code for many if...else-if statements. Apart from the switch case

if(a>0 && a<=5){
a=5;
}
else if(a>5 && a<=10){
a=10;
}
else if(a>10 && a<=15){
a=15;
}
else if(a>15 && a<=20){
a=20;
}
.
.
.
.
.
else if(a>95 && a<=100)
a=100;
}

I have gone through many posts but could not find the feasable solution.

Aucun commentaire:

Enregistrer un commentaire