Code: Select all
10 dim pc(99): rem will be used to calculate percentages later
20 let pc = 100: rem used to fill array
30 for i = 0 to 99: rem fill array loop
40 let pc(i) = i/pc: rem enter multiplier for each array position
50 next i: rem end loop
60 input "enter the number"; a: rem a is for the number and b for the percentage
70 input "now enter the percentage of that number you want to work out";b
80 print
90 print "{left}"; b ;"{left}% of"; a ;"is"; a*pc(b)
True story: The dev next to me was using division to work out percentages on a recent project. Apart from the rounding difference across PHP and Javascript that we were using, division wasn't always going to work. For instance, 99 / 33 is 3, and yet 33% of 99 is 32.67. You probably all know this, but percentages have a certain symmetry to them in that 33% of 99 is the same as 99% of 33 Mathematics is the reason that I want to improve my mathematics.
Regards,
Shaun.