I can't figure out why the numbers being retuned by this function are off from what they should be. For the data that is entered and multiplied by 0.158 the wrong values are being returned by the calculations. For example 242 * .185 should return 44.77 but instead it is returning 38.236. I really can't figure out where I have gone wrong with this.
import java.util.*;
public class converter {
public static void main(String[] args) {
String s = "242,948,275,879,304";
List<String> list = Arrays.asList(s.split(","));
String end = "";
Scanner reader = new Scanner(s);
for (int i = 0; i < list.size(); i++)
{
String str = list.get(i);
double j = Float.parseFloat(str);
double number = 0.158;
j = j * number;
System.out.println(j);
int k = (int) j;
end += k +",";
}
System.out.println(end);
}
}