I had to make a table showing different values for converting kg to lbs and I'm confused because when it compiles, some of the decimals show correctly and some of them show with several 0's added on with another number on the end. Please help, I've tried to do math.random, but I'm not sure how to tie it in with my program. Please help.
and this is some of the results I get//1 kg = 2.2 lbs public class kg_to_lbs { public static void main(String[] args) { //not sure if values are needed.. int kg = 1; double lbs = 2.20; //Table title System.out.println(" Kilograms to Pounds"); //First line headings System.out.println(" Kilograms | Pounds "); //do-while loop do { System.out.println(" " + kg + " | " + (kg * lbs) + " "); kg++; } while (kg <= 199); //end loop } }
1 | 2.2 2 | 4.4 3 | 6.6000000000000005 4 | 8.8 5 | 11.0 6 | 13.200000000000001