public static void main(String[] args) {
int n = 5;
ArrayList<Integer> distances = new ArrayList<Integer> ();
distances.add(70);
distances.add(113);
distances.add(1);
distances.add(1700000000);
distances.add(268000);
int i =0;
while(n-->0 & i<5)
{
int distance = distances.get(i);
int au = distance * (149597871 * 1000);
System.out.println(au);
i++;
}
}
So my code outputs this:
720702352
-431854056
-725984360
444733440
-1789971200
But the output should be this:
10471850970000
16904559423000
149597871000
254316380700000000000
40092229428000000
So my question is how do I fix this issue because I do not understand why it is giving me the wrong product. FYI, if you plug the equation into a calculator it works.