Which of the if statements below will best resolve the following problem? Cindy needs to purchase butter, she went to the store and wrote down the following prices, R14.85 for 500g, R21.95 for 750g and R 29.83 for 1kg. She wants to write a program to determine which one of the packets of butter is the most economical. Select one: a. if (price500 / 5) > (price750 / 7.5) then      if (price 500 / 5) > (price1000 / 10) then          display “The 500g packet is the most economical”      else          display “The 1kg packet is the most economical”      endif else      if (price750 . 7.5) > (price1000 / 10) then          display “The 750g packet is the most economical”      else               display “The 1kg packet is the most economical”      endif endif b. if (price500 / 5) < (price750 / 7.5) then      if (price 500 / 5) < (price1000 / 10) then          display “The 500g packet is the most economical”      else          display “The 1kg packet is the most economical”      endif else      if (price750 . 7.5) < (price1000 / 10) then          display “The 750g packet is the most economical”      endif endif c. if (price500 / 5) < (price750 / 7.5) then      if (price 500 / 5) < (price1000 / 10) then          display “The 500g packet is the most economical”      else          if (price750 . 7.5) < (price1000 / 10) then               display “The 750g packet is the most economical”          else               display “The 1kg packet is the most economical”      endif endif d. if (price500 / 5) < (price750 / 7.5) then      if (price 500 / 5) < (price1000 / 10) then          display “The 500g packet is the most economical”      else          display “The 1kg packet is the most economical”      endif else      if (price750 . 7.5) < (price1000 / 10) then          display “The 750g packet is the most economical”      else               display “The 1kg packet is the most economical”      endif endif

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter4: Control Structures I (selection)
Section: Chapter Questions
Problem 20PE: The cost of renting a room at a hotel is, say $100.00 per night. For special occasions, such as a...
icon
Related questions
icon
Concept explainers
Question

Which of the if statements below will best resolve the following problem?

Cindy needs to purchase butter, she went to the store and wrote down the following prices, R14.85 for 500g, R21.95 for 750g and R 29.83 for 1kg. She wants to write a program to determine which one of the packets of butter is the most economical.

Select one:
a.

if (price500 / 5) > (price750 / 7.5) then

     if (price 500 / 5) > (price1000 / 10) then

         display “The 500g packet is the most economical”

     else

         display “The 1kg packet is the most economical”

     endif

else

     if (price750 . 7.5) > (price1000 / 10) then

         display “The 750g packet is the most economical”

     else

              display “The 1kg packet is the most economical”

     endif

endif

b.

if (price500 / 5) < (price750 / 7.5) then

     if (price 500 / 5) < (price1000 / 10) then

         display “The 500g packet is the most economical”

     else

         display “The 1kg packet is the most economical”

     endif

else

     if (price750 . 7.5) < (price1000 / 10) then

         display “The 750g packet is the most economical”

     endif

endif

c.

if (price500 / 5) < (price750 / 7.5) then

     if (price 500 / 5) < (price1000 / 10) then

         display “The 500g packet is the most economical”

     else

         if (price750 . 7.5) < (price1000 / 10) then

              display “The 750g packet is the most economical”

         else

              display “The 1kg packet is the most economical”

     endif

endif

d.

if (price500 / 5) < (price750 / 7.5) then

     if (price 500 / 5) < (price1000 / 10) then

         display “The 500g packet is the most economical”

     else

         display “The 1kg packet is the most economical”

     endif

else

     if (price750 . 7.5) < (price1000 / 10) then

         display “The 750g packet is the most economical”

     else

              display “The 1kg packet is the most economical”

     endif

endif

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Operators
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
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage