I'm new to java and we have to create a program telling the user how much of their income will be taxed based on rates given out by the government of Canada. I am getting 2 errors, one saying that "variable federal might not have been initialized" and the other "variable provincial might not have been initialized. " Can someone tell me what that means?

Here's the program just incase:

class IncomeTax 
{
    public static void main (String[] args)
    {
        // DECLARE VARIABLES/DATA DICTIONARY 
        
        double income;   // The income of which the tax is being calculated.
        double totaltax; // The total income tax (in dollars) that was taken off the income.
        double avgTax;   // The total percentage of income tax was taken off the income
          
        double federal;       // tax by federal gov.  
        double provincial;   // tax by provincial gov
        
        // READ IN GIVENS  - use the class ITI1120
     
        System.out.println("Please enter your total income for the year");
        income = ITI1120.readInt( );
                    
        // BODY OF ALGORITHM
     
        if (income <= 37885.0)
        {
          federal = income * 0.15;
        }
        else
        {
          ;
        }
        if (income <=75769.0)
        {
          federal = (income - 37885.0) * 0.22 + 37885.0 * 0.15;
        }
        else 
        {
          ;
        }
        if (income <= 123184.0)
        {
          federal = (income - 75769.0) * 0.26 + (75769.0-37885.0) * 0.22 + 37885.0 * 0.15;
        }
        else
        {
          ;
        }
        if (income > 123184.0)   
        {
        federal = (income - 123184.0) * 0.29 + (123184.0 - 75769.0) * 0.26 + (75769.0-37885.0) * 0.22 + 37885.0 * 0.15;
        }
        
        
        if (income <= 36020.0)
        {
          provincial = income * 0.0605;
        }
        else
        {
          ;
        }
        if (income <= 72041.0)
        {
          provincial = (income - 36020.0) * 0.0915 + 36020.0 * 0.0605;
        }
        else 
        {
          ;
        }          
          if (income > 72041.0)
        {
          provincial = (income - 72041.0) * 0.1116 + (72041.0 - 36020.0) * 0.0915 + 36020.0 * 0.0605;
        }
                
        totaltax = (federal + provincial);
        avgTax = (totaltax /income) * 100.0;

        // PRINT OUT RESULTS AND MODIFIEDS
        
        System.out.println("$" + totaltax + " will be taken from your income due to taxes.");
        System.out.println("The average rate of tax that you are paying to the Government is " + avgTax + "%.");
    }
    
     
}

Thanks in advance,

Atul

well, im not sure, but your code says

income = ITI1120.readInt( );

and you declared income as a double.

And provincial also relies on income for its value, so thats why it doesn't work.

Good eye thanks
but the same problem is occuring after I made that change
any other suggestions?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.