Ask Question
14 July, 22:26

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;

+3
Answers (1)
  1. 14 July, 22:32
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers