Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2022-03-06 14:35:14

Hannibal lecter
Member
Registered: 2016-02-11
Posts: 392

if condition and math

The university bookstore has a Kilobyte Day sale every October 24, giving an 8 percent
discount on all computer accessory purchases if the price is less than $128, and a 16 percent
discount if the price is at least $128. Write a program that asks the cashier for the original price
and then prints the discounted price

solution :
{
If original price < 128
discount rate = 0.92
Else                              // i't mean if the other condition true which is (if original price ≥ 128) but the problem not here!
discount rate = 0.84

discounted price = discount rate x original price
}

my problem is what is the meaning of 0.92?
and what is the meaning of 0.84?
in the exercise it said discount only 8% mentioned and 16%, from where did we get 0.92 and 0.84???


because I solve it like that :
discount price = original price - DiscountedValue
example : 110
discount price = 110-8.8  // because discountPrice will be (8/100 * 110 = 8.8)...
this way of mine is gives the same answer! why the book used something like that and how the book find that rate?

Last edited by Hannibal lecter (2022-03-06 15:01:23)


Wisdom is a tree which grows in the heart and fruits on the tongue

Offline

#2 2022-03-07 10:17:28

Bob
Administrator
Registered: 2010-06-20
Posts: 10,140

Re: if condition and math

I think we've met this before.

To reduce by say 8% you need to calculate what 8% is and subtract from 100% of the price. So if the price is X you would do X - 0.08X = X(1 - 0.08) = 0.92X

So a multiplier for an 8% reduction is 0.92

And for 16%.       X - 0.16X = X(1 - 0.16) = 0.84X

Bob by


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

Board footer

Powered by FluxBB