Dear All:
Simple code to ask you your wages, get the tax rate, and give you the value of the tax owed first the dollars, as an int type, and then display the cents owed as a double or long.
What I can not work out how to do is set the significant number to two digits after the ".".
I have looked at the AIP and found "round.(a,2)" but I do not seem to get this to work.
The error I get is "can not find symbol".
symbol : method round(java.lang.Double,int);
location: class TaxBill
long ttaxDue = round(calcTaxDue, 2);
^
The code is as follows.
import java.util.Scanner; import static java.lang.Math.*; import java.lang.Math.*; import java.lang.Double; import java.lang.Enum.*; public class TaxBill { //public static void final RoundingMode HALF_UP; //This has errors but not what I want to concentrate on. public static void main(String[] args) { //Initalize the variable "ssalary" and get the input from the user. float ssalary = 00.00f; System.out.print("What is your current salary (in USD)?: $"); Scanner keyboard = new Scanner(System.in); ssalary = keyboard.nextFloat(); double ttaxRate = 0.00; System.out.print("What is your current tax rate?: %"); ttaxRate = keyboard.nextDouble(); Double calcTaxDue = (ssalary / 100) * ttaxRate; long ttaxDue = round(calcTaxDue, 2); //ROUND ROUND ROUND ROUND ROUND ROUND ROUND int ttaxDollars = (int) Math.floor(calcTaxDue); int ttaxCents = (int) ttaxDue - ttaxDollars; // so I need the ttaxDue value rounded so this calculation gives me the cents left, and I want to know how to round stuff. System.out.println("You made $" + ssalary); System.out.println("You paid in tax: $" + ttaxDollars); System.out.println("You paid in tax: c" + ttaxCents);
Thanks for any help.
SPACE MONKEY, (I buy space bananas!).