Answer to Question #184602 in Java | JSP | JSF for KYura

Question #184602

Suppose that overSpeed and fine are double variables. Assign the value to fine as follows: If 0 < overSpeed <= 5, the value assigned to fine is $20.00; if 5 < overSpeed <= 10, the value assigned to fine is $75.00; if 10 < overSpeed <= 15, the value assigned to fine is $150.00; if overSpeed > 15, the value assigned to fine is $150.00 plus $20.00 per mile over 15.


1
Expert's answer
2021-04-25T06:14:55-0400
public class Q184602 {
    public static void main(String[] args) {
        // overSpeed and fine are double variables
        double overSpeed=25;
        double fine=0;
        //Assign the value to fine as follows: 
        //If 0 < overSpeed <= 5, the value assigned to fine is $20.00;
        if(overSpeed>0 && overSpeed<=5){
            fine=20.00;
        }
        //if 5 < overSpeed <= 10, the value assigned to fine is $75.00; 
        else if(overSpeed>5 && overSpeed<=10){
            fine=20.00;
        }
        //if 10 < overSpeed <= 15, the value assigned to fine is $150.00; 
        else if(overSpeed>10 && overSpeed<=15){
            fine=150.00;
        }
        //if overSpeed > 15, the value assigned to fine is $150.00 
        //plus $20.00 per mile over 15.
        else if(overSpeed>15){
            fine=150.00+20.00*(overSpeed-15);
        }
        System.out.println("The fine is: "+fine);
        
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog