Problem:
I am in the process of making a Tax Calculator, where the user enter his details (Name, Income, Number of Children, etc.) and the programe calculates the total amount of tax upon the given values. However, I made the system calculate the values but now I want it to store the values such as the users Name, Income and no of children. I know that I need to use an arraylist but I am totally confused about how to set up one and intergrate it into the code I already have.
The code below is where the details from the user are typed in then these values are then used by the calculations I have set up. These calculations are then shown to the user.
Expand|Select|Wrap|Line Numbers
- InputStreamReader istream = new InputStreamReader(System.in) ;
- BufferedReader bufRead = new BufferedReader(istream) ;
- System.out.println("Welcome To The Rockall Tax Calculator");
- try {
- //When the user enters the information it will be stored in these strings
- System.out.println("Please Enter In Your First Name: ");
- String firstName = bufRead.readLine();
- System.out.println("What is your household income per year?: ");
- String houseIncome = bufRead.readLine();
- System.out.println("How many children are in your household?: ");
- String numberofChildren = bufRead.readLine();
- System.out.println("How many imported puffins are there?: ");
- String numberofPuffins = bufRead.readLine();
But
How do I go about storing the caluclated values (below) along with the name of the user into an ArrayList.
Expand|Select|Wrap|Line Numbers
- if ( income >= 100000 )
- {
- System.out.println("Hello " +firstName + ". Your U " + houseIncome + " is over U 100000 therefore you will pay no tax on children = U" + allowanceTax);
- System.out.println("The " + steppedTax + " will be taxed at 25% which = U" + total2);
- System.out.println("However, you earn more than U 100000 so the exceeding amount, which is U " + exceedAmount + " ,will be taxed 40% = U" + htax);
- System.out.println("As there are " + puffins + " puffins you will be charged 10% of U " + fullTotal1 + ", which is U " + fullTotal1*puffinTax);
- }
- else
- {
- System.out.println("Hello " +firstName + ". Your U " + income + " is under U 100000 therefore you will pay tax on" + children + " , which is = U" + allowanceTax);
- System.out.println("As you have " + children + " children you will be taxed at U " + allowanceTax);
- System.out.println("The tax owned on the amount of U " + total + " taxed at 25% is U " + tax);
- System.out.println("As there are " + puffins + " puffins you will be charged 10% of U " + fullTotal2 + ", which is U " + fullTotal2*puffinTax);
- }
If anyone could help me then I would be extremely grateful. As I need complete this program so that I am able to submit in time.
Thanks in advance,
thegreatest21