Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8798009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:58:47+00:00 2026-06-13T23:58:47+00:00

Thanks for reading, I am brand new with java and I am trying to

  • 0

Thanks for reading, I am brand new with java and I am trying to create a program.

So I have a method called public class mysystem in which i perform a loop on a array

for (int i = 0; i < tax.length; i++)

in the main method but I get errors all the time – it needs to be setted up that way as I will use that array twice once for calculating one value and second time for another value

The error I get in eclipse is

Exception in thread "main" java.lang.Error: Unresolved compilation problems:

tax cannot be resolved to a variable
tax cannot be resolved to a variable
tax cannot be resolved to a variable
tax cannot be resolved to a variable
tax cannot be resolved to a variable
tax cannot be resolved to a variable

at mysystem.taxAlone(mysystem.java:11)
at mysystem.main(mysystem.java:83)

On request the full code

 import java.util.Scanner;


 public class taxsystem{
            public static void taxAlone(double inputwage){
                    for (int i = 0; i < tax.length; i++)
                            {
                                    // Check what tax bracket the value falls in to
                                    if ((inputwage >= tax[i][0]) && (inputwage <= tax[i][1]))
                                            {
                                                    // Declare the tax variable
                                                    double taxValue;
                                                    // do the calculation - amount taxable * taxrate + Cumulative value
                                                    taxValue = ( ( (inputwage - tax[i][0]) * tax[i][2]) + tax[i][3]);
                                                    //rounding up or down!
                                                    int finalTax = (int)Math.round(taxValue);
                                                    //Print out the result!

                                                    System.out.println("You will be taxed £ "+ finalTax);
                                            }

                            }
            }

            public static void main(String[] args)
                    {

                            double[][] tax = new double[6][4];
                            // First Tax Band
                            tax[0][0] = 0;
                            tax[0][1] = 100;
                            tax[0][2] = 0;
                            tax[0][3] = 0; // 0 to start
                            // Second Tax Band
                            tax[1][0] = 101;
                            tax[1][1] = 150;
                            tax[1][2] = 0.1;
                            tax[1][3] = 0; // 0* 100 = 0
                            // Third Tax Band
                            tax[2][0] = 151;
                            tax[2][1] = 200;
                            tax[2][2] = 0.2;
                            tax[2][3] = 4.9; // 100 * 0 + 49 * 0.1 = 4.9
                            // Fourth Tax Band
                            tax[3][0] = 201;
                            tax[3][1] = 300;
                            tax[3][2] = 0.4;
                            tax[3][3] = 14.7;
                            // Fifth Tax Band
                            tax[4][0] = 301;
                            tax[4][1] = 400;
                            tax[4][2] = 0.6;
                            tax[4][3] = 54.3;
                            // Sixth Tax Band
                            tax[5][0] = 401;
                            tax[5][1] = 10000; // Dummy Value - Program is only assumed to
                                                                 // takes values up to 1000 pounds
                            tax[5][2] = 1.2;
                            tax[5][3] = 113.7;

                            // Display instructions and ask for value
                            System.out.println("Please enter the income earned to calculate tax");

                            Scanner read = new Scanner(System.in);

                            double wage = read.nextDouble();

                            taxAlone(wage);



                    }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:58:49+00:00Added an answer on June 13, 2026 at 11:58 pm

    The taxAlone method does not have visibility for the tax variable. Can resolve in one of two ways:

    1. Add the tax variable as a static variable, e.g. private static double[][] tax and work with just that copy
    2. Add the tax variable as an argument to the taxAlone method, e.g. public static void taxAlone(double[][] tax, double inputwage) and be sure to pass the constructed object as an argument to the method.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for reading. I'm a bit new to jQuery, and am trying to make
Thanks for reading this. I have no idea why this is throwing a NullReferenceException
Thanks for reading. I have done a search, read multiple posts (lost count) and
thanks for your reading. I am trying to modify Jquery Nivo Zoom plugin to
Thanks for reading. I'm trying to put a label and an image on a
Thanks for reading this. I have 2 MySQL databases - master for writes, slave
First off I am brand new to C and have been thrown into a
Thanks for reading and answering in advance! I wrote a simple C# program that
Thanks for reading. I'm trying to use CoreImage in iOS 5 to alter the
Hello and thanks for reading. I am trying to take an OOP approach to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.