hello! I am currently making a beginner level program that makes an addition and stores it in a map to make some tests on functions! But when i wish to store the variables in the map, their value is 0 in the function! Here is the code. If anyone knows how to fix this i'd appreciate it!
public class Additions {
static Map<String, Integer>storeResult = new HashMap<String, Integer>();
static int a;
static Scanner keyboard = new Scanner(System.in);
static Scanner doYouContinue = new Scanner(System.in);
static int b;
static String clientsChoice;
public static void main(String[] args) {
// TODO Auto-generated method stub
do{
System.out.println("Donnez un entier:");
int a = keyboard.nextInt(); // FOR TEST I GAVE 3
System.out.println("Donnez un autre entier:");
int b = keyboard.nextInt(); // FOR TEST I GAVE 4
additionate(a, b);
}while(!clientsChoice.equals("non"));
}
private static void additionate(int a, int b) {
// TODO Auto-generated method stub
final int z = a+b;
System.out.print(" C'est egal à ");
System.out.println(z); // PRINTED 7
storeInMap(z);
}
private static void storeInMap(int z) {
// TODO Auto-generated method stub
System.out.println(a); // THIS INDICATES 0
String stringA = String.valueOf(a);// MAKING SOME TESTS TO TRY TO FIX IT
String stringB = String.valueOf(b);
storeResult.put(stringA+"+"+stringB, z);
continuing();
}