Computer Science Canada

Calculating pay per weekly hours

Author:  lucklesslily [ Wed Oct 28, 2015 9:15 am ]
Post subject:  Calculating pay per weekly hours

I can't figure out how to do something in Turing, I'm trying to write out a program that calculates the weekly pay for an employee. So if they work 20 hours or less they're payed $9/h, etc.

It looked like this @ one point:

if workHours <= 20
then workHours * 9
elsif workHours > 20
then workHours * 11
elsif workHours >= 40
then workHours * 17
end if

and obviously it's not working, but I can't seem to find out how else to figure out the weekly pay per hours... Embarassed

Author:  Insectoid [ Thu Oct 29, 2015 12:11 am ]
Post subject:  RE:Calculating pay per weekly hours

Quote:
then workHours * 9


The problem here is that you're creating a new value by multiplying two numbers together, but you're not storing that value in a variable. Maybe call that variable 'pay'. Then that line should look like this:

then pay := workHours * 9


: