Ask Question
4 February, 03:25

What will be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 100; if (purchase > 1000) discountRate = 0.05; else if (purchase > 750) discountRate = 0.03; else if (purchase > 500) discountRate = 0.01;

+1
Answers (1)
  1. 4 February, 04:26
    0
    The value of discountRate after the following statements are executed

    double discountRate = 0.0;

    int purchase = 100;

    if (purchase > 1000) discountRate = 0.05;

    else if (purchase > 750) discountRate = 0.03;

    else if (purchase > 500) discountRate = 0.01;

    is 0.0

    Explanation:

    The discount rate is declared as a double; double discountRate = 0.0;

    The purchase is declared as integer; int purchase = 100;

    The first if statement shows if purchase > 1000 then the discountRate is 0.05

    The second if statement shows if purchase > 750then the discountRate is 0.03

    The third if statement shows if purchase > 500 then the discountRate is 0.01

    Since none of these statements are true, the original discountRate is printed.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What will be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 100; 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