Computer Science Canada

What's wrong here?? (turing)

Author:  boocloud214 [ Fri Feb 29, 2008 7:33 pm ]
Post subject:  What's wrong here?? (turing)

var pph : real
var it : real
var cp : real
var ue : real
var total : real
var hw : int

put "How much do you get payed per hour? "..
get pph
put "How many hours have you worked? "..
get hw
put "You get payed $", total


it := 0.24
cp := 0.7
ue := 0.2
total := pph * (it+cp+ue) * hw

Lol help please??
Thanks ^-^

*also, if someone wouldn't mind telling me how to colour the background and font, i would very miuch apreciate it*

Author:  asd [ Fri Feb 29, 2008 7:43 pm ]
Post subject:  RE:What\'s wrong here?? (turing)

i'm going to ignore the "wrong section" problem since I'm not a mod and can't do anything about it.

YOU HAVE TERRIBLE VARIABLE NAMES.

as far as I can tell, there's NOTHING wrong with it. it does exactly what you told it to.

PEBKAC, basically

Author:  Nick [ Fri Feb 29, 2008 7:43 pm ]
Post subject:  RE:What\'s wrong here?? (turing)

how can you output your total before you calculate it?

Author:  Tony [ Fri Feb 29, 2008 7:44 pm ]
Post subject:  RE:What\'s wrong here?? (turing)

put "You get payed $", total

what is the value of total?

Author:  boocloud214 [ Fri Feb 29, 2008 7:45 pm ]
Post subject:  Re: RE:What\'s wrong here?? (turing)

momop @ Fri Feb 29, 2008 7:43 pm wrote:
how can you output your total before you calculate it?


Idfk what to put in the beginniner also, im new >.>

Author:  Nick [ Fri Feb 29, 2008 7:47 pm ]
Post subject:  RE:What\'s wrong here?? (turing)

simply move the line where you output your total to the end after your calculations

Author:  boocloud214 [ Fri Feb 29, 2008 7:48 pm ]
Post subject:  Re: RE:What\'s wrong here?? (turing)

Tony @ Fri Feb 29, 2008 7:44 pm wrote:
put "You get payed $", total

what is the value of total?


Im trying to make it so it calculates what i put in as pph and hw

Author:  Tony [ Fri Feb 29, 2008 7:55 pm ]
Post subject:  RE:What\'s wrong here?? (turing)

that does not answer the question.

if I enter pph to be 2 and hw to be 2, what is the value of total?

Author:  technograff [ Fri Feb 29, 2008 7:59 pm ]
Post subject:  Re: What's wrong here?? (turing)

code:
var pph : real
var total : real
var hw : int

put "How much do you get payed per hour? "..
get pph
put "How many hours have you worked? "..
get hw

total := pph * (1.14) * hw

put "You get payed $", total



Is this what you're looking for? You just had to move the calculation above the output, the program can't output the answer if it hasn't calculated it yet.

Author:  boocloud214 [ Fri Feb 29, 2008 8:04 pm ]
Post subject:  Re: What's wrong here?? (turing)

technograff @ Fri Feb 29, 2008 7:59 pm wrote:
code:
var pph : real
var total : real
var hw : int

put "How much do you get payed per hour? "..
get pph
put "How many hours have you worked? "..
get hw

total := pph * (1.14) * hw

put "You get payed $", total



Is this what you're looking for? You just had to move the calculation above the output, the program can't output the answer if it hasn't calculated it yet.


Yes! but i need to include the it,cp, and the eu (the tax that's in the whole equasion =\

Author:  technograff [ Fri Feb 29, 2008 8:08 pm ]
Post subject:  RE:What\'s wrong here?? (turing)

Well, since they still add up to 1.14, I don't really see the need, but if you need to, just take your original code, then take

code:

put "You get payed $", total


and put it at the very end of the program.

Edit: typos

Author:  richcash [ Fri Feb 29, 2008 8:36 pm ]
Post subject:  Re: What's wrong here?? (turing)

Yes, as everyone is saying, move the line that outputs total to the bottom and you will eliminate the syntax error.

But there are other issues with the program. First of all, your taxes add up to 114%! How can you take 114% off of someone's pay check? Your tax rates are definetely wrong (check the decimal places). Secondly, if cp, it, and eu are tax rates to be deducted off of a pay, then adding them up and multiplying by the subtotal will not give you the new total, it will give you the total tax that needs to be deducted.

Author:  technograff [ Fri Feb 29, 2008 9:45 pm ]
Post subject:  RE:What\'s wrong here?? (turing)

The taxes are not 114%, they are 14%. When the decimals are added you get a factor of 1.14, which means that .14 of the pay is added to it, does it not?

Author:  richcash [ Fri Feb 29, 2008 10:07 pm ]
Post subject:  Re: What's wrong here?? (turing)

In which country do they add a percentage to your paycheck and call it taxes? Exactly.

The total is calculated wrong, so in effect .14 is added to the paycheck in this program. But what is intended is to deduct the taxes from the paycheck. If you use 1.14 as the tax rate and deduct it, it would be 114%. And considering that the 1.14 is composed of different taxes, I'll assume that the decimal places are wrong. The numbers are probably supposed to be 0.24, 0.07, and 0.02 or something like that.

Author:  Nick [ Fri Feb 29, 2008 10:44 pm ]
Post subject:  RE:What\'s wrong here?? (turing)

if you're trying to reduce by 14% then it should be 1.0 - 0.14 which is 0.86 that will reduce by 14%

Author:  SIXAXIS [ Sun Mar 02, 2008 2:11 pm ]
Post subject:  Re: What's wrong here?? (turing)

Put your calculations before you output it on to the screen. Remember, computers do things in order (well at least for the most part in Turing).

Turing:
var pph : real
var it : real
var cp : real
var ue : real
var total : real
var hw : int

put "How much do you get payed per hour? " ..
get pph
put "How many hours have you worked? " ..
get hw

it := 0.24
cp := 0.7
ue := 0.2
total := pph * (it + cp + ue) * hw

put "You get payed $", total

That's how it should be. Also, make better variable names.

Author:  Sean [ Sun Mar 02, 2008 7:11 pm ]
Post subject:  Re: What's wrong here?? (turing)

Also, you requested colouring of background and text..

Text..
Turing:

colour (%Colour ID Number)


Background...
Turing:

colourback (%Colour ID Number)
cls


Check the RBG modules for your colours. Heres the one I worked on.

Turing:

colour (0)
for c:1..255
    colourback(c)
    put " ",c," "..
end for


: