The decision table below shows fines imposed for speeding vi
The decision table below shows fines imposed for speeding violations. Write a code segment that assigns the correct fine to type double variable fine based on the value of type int variable speed. Speed (mph) Fine ($) 65 or less 0 66-70 15.00 71-75 30.00 76-80 75.00 over 80 100,00
Solution
double fine;
int speed;
if (speed<=65) {
fine=0;
}
else if (speed>=66 && speed <=70)
{
fine=15.00;
}
else if (speed>=71 && speed <=75)
{
fine=30.00;
}
else if (speed>=76 && speed <=80)
{
fine=75.00;
}
else{
fine=100.00;
}
