Ask Question
14 December, 12:53

What would be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 1250; if (purchase > 1000) discountRate =.05; if (purchase > 750) discountRate =.03; if (purchase < 2500) discountRate =.01; else discountRate = 0;

+3
Answers (1)
  1. 14 December, 16:50
    0
    The value of discountRate would be 0.01

    Explanation:

    double discountRate = 0.0;

    int purchase = 1250;

    if (purchase > 1000)

    discountRate =.05;

    if (purchase > 750)

    discountRate =.03;

    if (purchase < 2500)

    discountRate =.01;

    else discountRate = 0;

    discountRate is declared as 0.0 then purchase is 1250. But the entire if statement is sequential, that is; all the if statement are executed.

    first if-statement assign. 05 to discountRate because purchase is greater than 1000.

    Next if-statement re-assign. 03 to discountRate because purchase is greater than 750.

    The last if-statement re-assign. 01 to dicountRate because purchase is less than 2500. Since this is the last if statement executed, the value of discountRate is. 01
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What would be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 1250; if ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers