Ask Question

A store provides 10 percent discount on all items with a price of at least $100. No discount is otherwise applicable. Which of the following DOES NOT correctly compute the discount? Group of answer choices double discount = 0; if (price > = 100) { discount = 0.10 * price; } double discount; if (price = 100) { discount = 0.1 * price; } else { discount = 0; } double discount = 0.10 * price; if (price < = 100) { discount = 0; }

+4
Answers (1)
  1. 21 June, 11:35
    0
    The last option of the following question is not correct, which is:

    double discount = 0.10 * price;

    if (price < = 100)

    {

    discount = 0;

    }

    Explanation:

    Because the formula of the discount is not initialized inside the condition section but, in the last option the formula is initialized at that time when the variable is declared.

    This option may be right, if the formula is initialized inside the else section like:

    double discount = 0;

    if (price < = 100)

    {

    discount = 0;

    }

    else

    {

    discount = 0.10 * price;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “A store provides 10 percent discount on all items with a price of at least $100. No discount is otherwise applicable. Which of the ...” 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