This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-10-10 11:50:43

lolzmaster
New Scratcher
Registered: 2011-10-06
Posts: 5

How to add tax?

Hello Scratch forums!

Just a quick question -

I can't figure out how to add tax to my total cost of pizza. Here is my calculation:

Cost of pizza* ($10.00) + Cost of toppings* ($2.50) and then the two taxes: PST and GST (Now known as the "HST") PST = 8% and GST = 6%.

Whenever I add them all up on Scratch; I get 0.1.

Can anyone help?

Thanks!

Offline

 

#2 2011-10-10 15:11:32

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: How to add tax?

I would recommend something like this:
http://www.freeimagehosting.net/newuploads/304fd.gif
That works out to $14.30, which seems accurate.


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

#3 2011-10-10 20:28:22

lolzmaster
New Scratcher
Registered: 2011-10-06
Posts: 5

Re: How to add tax?

hmnwilson wrote:

I would recommend something like this:
That works out to $14.30, which seems accurate.

Thanks hmnwilson; although it seems that it won't set the varibles to the correct value :?.

I need help ASAP.

Thanks!!!!!

Offline

 

#4 2011-10-10 20:38:30

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: How to add tax?

lolzmaster wrote:

hmnwilson wrote:

I would recommend something like this:
That works out to $14.30, which seems accurate.

Thanks hmnwilson; although it seems that it won't set the varibles to the correct value :?.

I need help ASAP.

Thanks!!!!!

If you have "Cost of pizza" and "Cost of toppings" set correctly, it should work. Or are you talking about something else?


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

#5 2011-10-11 20:35:31

lolzmaster
New Scratcher
Registered: 2011-10-06
Posts: 5

Re: How to add tax?

Unfortunatally; it doesn't. The only answer I get is 0.0; which; obvusally; is incorrect. It sets the tax to 0.0 (both of them).

Thanks for your help hmnwilson; VERY helpful!

Offline

 

#6 2011-10-11 20:36:40

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: How to add tax?

lolzmaster wrote:

Unfortunatally; it doesn't. The only answer I get is 0.0; which; obvusally; is incorrect. It sets the tax to 0.0 (both of them).

Thanks for your help hmnwilson; VERY helpful!

I think it's because Scratch automatically rounds to tenths, and you need hundredths...

Offline

 

#7 2011-10-11 21:38:39

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: How to add tax?

lolzmaster wrote:

Unfortunatally; it doesn't. The only answer I get is 0.0; which; obvusally; is incorrect. It sets the tax to 0.0 (both of them).

Hmm, that's weird...

This may be a long shot, but you're not putting a dollar sign ($) in front of the number, are you? You may be tricking Scratch into thinking it's a string, which will automatically return 0 if used with the math blocks. When you're doing math using variables, they should only contain the numbers 0-9, a period, or a comma (for decimals).

In any case, I've uploaded a project here which you can compare with your scripts. Make sure when you enter the values, don't include the dollar sign.


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

Board footer