Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 What's wrong here?? (turing)
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
boocloud214




PostPosted: 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*
Sponsor
Sponsor
Sponsor
sponsor
asd




PostPosted: 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
Nick




PostPosted: 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?
Tony




PostPosted: 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?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
boocloud214




PostPosted: 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 >.>
Nick




PostPosted: 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
boocloud214




PostPosted: 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
Tony




PostPosted: 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?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
technograff




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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%
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: