1 Replies - 3718 Views - Last Post: 29 May 2010 - 11:10 AM Rate Topic: -----

#1 alikhan2655@gmail.com  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10807
  • View blog
  • Posts: 40,288
  • 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())); 


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1