Posted: 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.
boocloud214
Posted: 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 =\
technograff
Posted: 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
richcash
Posted: 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.
technograff
Posted: 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?
richcash
Posted: 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.
Nick
Posted: 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%