I am making a Calculator and have the classes called addition, subtraction, multiplication and division and another class called Calculation and need them all to take the data from Calculation and then change it's Operator an example of the code:
public static void addition(){
calculation(); //imports calculation
for(int counter=0; counter < list.size(); counter++){
answer += list.get(counter);
}
System.out.println("The sum of these numbers is " + answer);
}
I simplified my Calculation class so it's easier to understand:
public static void calculation(){
List<Double> list = new ArrayList<Double>();
do{
list.add(scan.nextDouble());
}while(true)
After this I want to be able to use the List in my Addition class yet I keep getting errors on list that say "list cannot be resolved" and it wants me to create a local variable. I want it to take the list from Calculation and then allow me to change it's outcome.
How can I allow it to use 'list' in my Addition class?