I'm having some problem with my code. It works fine when I compile it until I get to the point when the numbers divide. I'm not getting numbers with decimal, only zero. As you can see, I already changed the last variables to double but it didn't have any meaningful result.
What must I do to change this?
int[] arr = new int[2];
System.out.println("enter two numbers: ");
arr[0] = sc.nextInt();
arr[1] = sc.nextInt();
int summa = arr[0]+arr[1];
System.out.println("What's "+arr[0]+" + "+arr[1]+" ?");
int vad = sc.nextInt();
if (summa == vad)
System.out.println("Correct!");
else
System.out.println("Wrong - The right answer is "+summa);
int summa2 = arr[0]-arr[1];
System.out.println("What's "+arr[0]+" - "+arr[1]+" ?");
int vad2 = sc.nextInt();
if (summa2 == vad2)
System.out.println("Correct!");
else
System.out.println("Wrong - The right answer is: "+summa2);
int summa3 = arr[0]*arr[1];
System.out.println("What's "+arr[0]+" * "+arr[1]+" ?");
int vad3 = sc.nextInt();
if (summa3 == vad3)
System.out.println("Correct!");
else
System.out.println("Wrong - The right answer is "+summa3);
double summa4 = arr[0]/arr[1];
System.out.println("What's "+arr[0]+" / "+arr[1]+" ?");
double vad4 = sc.nextInt();
if (summa4 == vad4)
System.out.println("Correct!");
else
System.out.println("Wrong - The right answer is "+summa4);
}
}