Answer to Question #184589 in Java | JSP | JSF for KimY

Question #184589

Suppose that sale and bonus are double variables. Write an if...else statement that assigns a value to bonus as follows: If sale is greater than $20,000, the value assigned to bonus is 0.10; If sale is greater than $10,000 and less than or equal to $20,000, the value assigned to bonus is 0.05; otherwise, the value assigned to bonus is 0.


1
Expert's answer
2021-04-24T11:19:41-0400
public class Q184589 {
    public static void main(String[] args) {
        //sale and bonus are double variables.
        double sale=25000;
        double bonus;
         //Write an if...else statement that assigns a value to bonus as follows: 
         //If sale is greater than $20,000, the value assigned to bonus is 0.10; 
         if(sale>20000){
             bonus=0.10;
         }
         //If sale is greater than $10,000 and less than or equal to $20,000, the 
         //value assigned to bonus is 0.05;
         else if(sale>10000 && sale<=20000){
             bonus=0.05;
         }
         // otherwise, the value assigned to bonus is 0.
         else{
              bonus=0.0;
         }
        System.out.println("The bonus is: "+bonus);
        
    }
}

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