if ((weight >=240 ) && (weight<=265))
{
val = 172;
bolt = "AG-4.500" ;
}
else
{
val = 186;
bolt = "Uknown";
}
The else there is only associated with the last if. The last if is false so the else executes and makes val= 186 and bolt = "AG-4.500".
To fix it make every if statement after the first one else if.
if ((weight >= 30) && (weight<=35))
{
val = 0;
bolt = "AL-0.500" ;
}
else if ((weight >= 39) && (weight<=45))
{
val = 14;
bolt = "AL-0.750" ;
}
else if ((weight >= 46) && (weight<=52))
{
val = 28;
bolt = "AL-1.000" ;
}
Ans so on. You should end up with one if, several else if and one else.