Computer Science Canada Simple Question |
Author: | Slnj [ Sun Sep 19, 2010 3:41 pm ] |
Post subject: | Simple Question |
Hi guys it's been a while since i been on this site, and school just started and i took another computer science class and I'm learning java now ![]() Quote: Write a program that calculates the amount of tax on $5.75 saves it to a new variable and then outputs the information on the screen. This is what i tried so far. Quote: public class problem6
{ public static void main (String[] args) { double a = 5.75 / 0.13; double b = a - 5.75; System.out.println (" The tax on 5.75 is " + a + " , the original price is " + b); } } This is the out put i get Quote: The tax on 5.75 is 44.230769230769226 , the original price is 38.480769230769226
Am i doing something wrong? [/quote] |
Author: | techietim [ Sun Sep 19, 2010 4:46 pm ] | ||
Post subject: | Re: Simple Question | ||
|
Author: | TheGuardian001 [ Sun Sep 19, 2010 4:47 pm ] |
Post subject: | Re: Simple Question |
Calculating tax is multiplying by the tax rate, not dividing by. 5.75 * 0.13 = 13/100ths of 5.75 = 0.7475 dividing by any number between 1 and 0 will increase the number. Dividing by 0.13 is the same as multiplying by about 7.7. |