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? explain your choice. a) double discount = 0; if (price >= 100) { discount = 0.10 * price; } b) double discount = 0.10 * price; if (price <= 100) { discount = 0; } %3!

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter4: Making Decisions
Section: Chapter Questions
Problem 16RQ
icon
Related questions
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? explain your choice.
a) double discount = 0;
if (price >= 100)
{
discount = 0.10 * price;
}
b) double discount = 0.10 * price;
if (price <= 100)
{
discount = 0;
}
c) double discount;
if (price < 100)
{
discount = 0;
}
else
{
discount = 0.10 * price;
}
d) double discount = 10;
if (price >= 100)
{
discount = 0.1 * price;
}
else
{
discount = 0;
}
Transcribed Image Text: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? explain your choice. a) double discount = 0; if (price >= 100) { discount = 0.10 * price; } b) double discount = 0.10 * price; if (price <= 100) { discount = 0; } c) double discount; if (price < 100) { discount = 0; } else { discount = 0.10 * price; } d) double discount = 10; if (price >= 100) { discount = 0.1 * price; } else { discount = 0; }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning