# Functions - if statement in equation: applying discount to total price for up to 10 products

I came across this question on a test.

A video game store sells video games for \$30 each. The store has a coupon for$9 off the total purchase for up to 10 games.

Determine the equation of the function that describes the relationship between the total cost and the number of video games a customer buys.

I am in grade 11 and with the things we learned, I don't think there is a way to solve this. In code, I can figure out an easy way of solving this by using if statements. I am not sure about how to solve this in math?

I was thinking:

Let c be total cost
Let g be one game
c = g(30) - 9


But that would not work for more than the discount.

How would one go about doing this?

I think your answer is correct and that the question is confusing. As it's written, the calculation of the discount doesn't depend at all on how many games you buy, as long as you buy at least one. The "up to 10 games" has no effect. So yes, the equation is $$c = 30g -9 .$$
That's a better way to write it than $g(30)$, and you should probably say "let $g$ be the number of games".
$$c = \begin{cases} 21g & (1 \le g \le 10) \\ 210 + 30(g-10) & (10 < g) \end{cases}$$