# Calculate Property Tax Program

Page 1 of 1

## 1 Replies - 4767 Views - Last Post: 29 May 2010 - 11:10 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=175611&amp;s=92f91707d95350a8192697271faabdbb&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 alikhan2655@gmail.com

Reputation: 0
• Posts: 3
• Joined: 28-May 10

# Calculate Property Tax Program

Posted 29 May 2010 - 10:41 AM

Hi,

I am taking my first programming course and I got this assignment "Property Tax."

Description:
Write a program to calculate the property tax. Property tax is calculated on 92% of the assessed value of the property. For example, if the assessed value is \$100,000.00, the property tax is on \$92,000.00. Assume that the property tax rate is \$1.05 for each \$100.00 of the assessed value. Your program should produce an output similar to the following. The following test class generates the following output. Write the class PropertyTax.

I tried to build it but I am getting an error msg. What is wrong with this program? I am using netbeans... getting the exception error... I am pasting the code if you can please check... Thank you so much!

Error Message Description:

The error msg is:

run:
Assessed value \$100,000.00
Taxable amount \$92,000.00
Tax rate for each \$100.00 is \$1.05
Property tax is \$966.00
----------------------------------
Assessed value \$150,000.00
Taxable amount \$138,000.00
Tax rate for each \$100.00 is \$1.05
Property tax is \$1,449.00
----------------------------------
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code
at TestPropertytax.main(TestPropertyTax.java:30)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

```
class PropertyTax
{
private double assessedvalue;
private double taxrate;
private static double taxableamount;
private static double propertytax;
private static double totaltaxrevenue;

public PropertyTax(double AssessedValue, double TaxRate)
{
assessedvalue = AssessedValue;
taxrate = TaxRate;
taxableamount = assessedvalue*.92;
propertytax = taxableamount*(taxrate/100);
}

public double totalTax(PropertyTax pT)
{
return this.calculate() + pT.calculate();
}

public double calculate()
{
return propertytax = taxableamount*(taxrate/100);
}

public double getTax()
{
return propertytax;
}

public double getTaxableAmount()
{
return taxableamount;
}

public double getAssessedValue()
{
return assessedvalue;
}

public double getTaxRate()
{
return taxrate;
}

}

```

The test class:

```import java.text.NumberFormat;

class TestPropertytax
{
public static void main(String[] arg)
{
NumberFormat nf = NumberFormat.getCurrencyInstance();

PropertyTax p1 = new PropertyTax(100000, 1.05);
p1.calculate();
print(p1, nf);
System.out.println("----------------------------------");

PropertyTax p2 = new PropertyTax(150000, 1.05);
p2.calculate();
print(p2, nf);
System.out.println("----------------------------------");

System.out.println("Total tax revenue " + nf.format(PropertyTax.totalTax()));
System.out.println("--------- End of report ----------");
}

static void print(PropertyTax p, NumberFormat nf)
{
System.out.println("Assessed value " + nf.format(p.getAssessedValue()));
System.out.println("Taxable amount " + nf.format(p.getTaxableAmount()));
System.out.println("Tax rate for each \$100.00 is " + nf.format(p.getTaxRate()));
System.out.println("Property tax is " + nf.format(p.getTax()));
}

```

Is This A Good Question/Topic? 0

## Replies To: Calculate Property Tax Program

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11447
• Posts: 43,145
• Joined: 27-December 08

## Re: Calculate Property Tax Program

Posted 29 May 2010 - 11:10 AM

When I compiled your code, I actually got a different error. At this line, I got a different error. You do not define the method toalTax() in the PropertyTax class as static (so you must invoke it from a Property tax Object, not the class name), and the totalTax() method accepts a PropertyTax object as a parameter.
```System.out.println("Total tax revenue " + nf.format(PropertyTax.totalTax()));

```