Results 1 to 3 of 3

Thread: Wetaxualot

  1. #1
    Bentino is offline Member
    Join Date
    Feb 2012
    Posts
    17
    Rep Power
    0

    Default Wetaxualot

    greetings everyone,this is my first program that i am writing and i have a few issues. Here are my instructions: in a county you are taxed the amount of land you own as follows: for every full acre of land you own, you are charged $2357.19 in taxes and for every foot of land you have that does not make up an acre, you are charged an additional $0.06 in taxes.
    Task: Write a program that asks the user to enter the number of square feet of land they own and then print out their tax bill(with two spaces after the decimal points for the cents amount). N.B. you might find it useful to know that there are 43560 square feet in one acre.

    this is what i have so far:

    import java.util.*;

    public class Wetaxualot {

    public static void main(String[] args)
    {
    // Declare the variables
    double taxbill;
    double taxbillextra; // The additional amount of tax charged
    int squarefeet;
    final double conversionrate = 0.0541136364; // Used to find the tax bill amount
    Scanner myReader = new Scanner(System.in);

    // Prompt User for number of square feet of land
    System.out.print("How many square feet are there in your property :");
    squarefeet = myReader.nextInt();


    // Calculate the tax based on the amount of land in square feet
    // Rate established by 2357.19/43560
    taxbill = squarefeet/conversionrate;
    taxbillextra = (squarefeet % 43560) * 0.06;


    // Return/ Print the amount of tax the User should pay
    System.out.printf("Your tax bill will be $%.4" , taxbill + taxbillextra);
    }



    }

    once i run it, the console says this:
    How many square feet are there in your property :456789
    Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '.'
    at java.util.Formatter.checkText(Unknown Source)
    at java.util.Formatter.parse(Unknown Source)
    at java.util.Formatter.format(Unknown Source)
    at java.io.PrintStream.format(Unknown Source)
    at java.io.PrintStream.printf(Unknown Source)
    at Wetaxualot.main(Wetaxualot.java:27)

    now, i am not quite sure how to correct this, if anyone could assist me as soon as possible, it would be much appreciated.
    thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Wetaxualot

    First of all, the error tells you what line your problem is on, and in fact tells you what the matter is. To simplify things, your problem is here:

    Java Code:
    System.out.printf("Your tax bill will be $%.4" , taxbill + taxbillextra);

    This: "%.4" doesn't make sense for printf. You'll want to check your reference on how to use printf and you'll see the correct way to use formatting constants.

  3. #3
    Bentino is offline Member
    Join Date
    Feb 2012
    Posts
    17
    Rep Power
    0

    Default Re: Wetaxualot

    alright, i shall do that yeah.

    thanks for the help man

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •