
-----------------------------------
5pirit
Mon Feb 13, 2012 10:01 pm

Can someone give me an idea on how to approach this problem?
-----------------------------------
Hey guys. Can some one give me any idea on how to approach this question? 
The Prom Committee at your school will sell tickets at $65 per 
person. Expenses include the cost of the food, the DJ, the 
hall, the decorations, and the waiting staff. To these 
expenses, add $100 for miscellaneous expenditures. Write a 
program to ask for each of the expense totals incurred and 
then calculate and output to the committee how many tickets 
they must sell to break even.

Thanks!

-----------------------------------
crossley7
Mon Feb 13, 2012 10:58 pm

RE:Can someone give me an idea on how to approach this problem?
-----------------------------------
This is a relatively simple problem.  You probably want to calculate total cost then find out how many tickets it takes to have an income that is equal to or greater than the expenses

If some costs are per person, then just subtract that from the cost of ticket rather than add to the total expense.  Basically combine variable expenses/income and constant expenses into 2 values and solve for a single value.

ceil (expenses/cost of ticket)

-----------------------------------
Velocity
Tue Feb 14, 2012 4:49 pm

RE:Can someone give me an idea on how to approach this problem?
-----------------------------------
crossley, i have a question never understood why ceil when you can just do expenses div cost of ticket to just get the whole number? isnt it more faster and efficient?

-----------------------------------
Dreadnought
Tue Feb 14, 2012 5:39 pm

Re: Can someone give me an idea on how to approach this problem?
-----------------------------------
@velocity They aren't the same. Try running this:
put "5 div 2 = ":18, 5 div 2
put "ceil (5 / 2) = ":18, ceil (5 / 2)
put "round (5 / 2) = ":18, round (5 / 2)
put "floor (5 / 2) = ":18, floor (5 / 2)
put ""
put "-5 div 2 = ":18, -5 div 2
put "ceil (-5 / 2) = ":18, ceil (-5 / 2)
put "round (-5 / 2) = ":18, round (-5 / 2)
put "floor (-5 / 2) = ":18, floor (-5 / 2)
Can you figure out what each function does? Why do you think crossley7 chose ceil over div? (remember that we are talking about paying expenses)

As for efficiency, div may (I'm not sure) actually be less efficient, but negligibly so.

-----------------------------------
crossley7
Tue Feb 14, 2012 11:31 pm

RE:Can someone give me an idea on how to approach this problem?
-----------------------------------
div in this case would be the same as floor is you are doing integer division, but I am assuming real values here and also wanting it to round up.

Ceil - will round up to the nearest integer
floor - will round down to the nearest integer
round - will round up or down to the nearest integer
div - will perform integer division

You need to know the slight (though significant) differences between these functions.  When dealing with integers, div and floor will give you the same result, but div cannot be used once there are real values involved

-----------------------------------
Dreadnought
Wed Feb 15, 2012 12:31 pm

Re: Can someone give me an idea on how to approach this problem?
-----------------------------------
@crossley Actually, div and floor are not quite the same. Floor rounds toward negative infinity while div rounds toward zero. This means that div is equivalent to the floor of a division when the result is positive. When the result is negative, div is equivalent to the ceil of a division. Of course, ceil rounds toward positive infinity and round rounds toward the nearest integer.

-----------------------------------
RandomLetters
Wed Feb 15, 2012 9:53 pm

RE:Can someone give me an idea on how to approach this problem?
-----------------------------------
More simply,

Div rounds towards 0
Ceil rounds up
Floor rounds down

Important stuff to know.

-----------------------------------
Velocity
Thu Feb 16, 2012 12:45 am

RE:Can someone give me an idea on how to approach this problem?
-----------------------------------
oh okay thanks, that cleared some things up
