alright basically what the program does is convert Kilograms into pounds, then displays its on a table. There are two problems i am having the first one is getting rid of the even numbers. I've been trying combinations of modulator and the NOT expression and so far have been unsuccessful and nothing prints out in the display. I was thinking that i could possibly list out the even numbers in the range 1-199 in a if statement and then do the modulator, but that is extremely tedious and not very practical. the other problem would be using the System.out.printf i want to format the table so that the numbers that print up under the pounds side of the table only go out to 3 decimal places. If someone could point in the right direction that would be very much appreciated.

public class KilogramsToPounds {

    public static void main(String[] args) {
  	System.out.println("Kilograms\t\tPounds");
   	System.out.println("-----------------------------");
    	int Kilo = 1;
    	if (Kilo % 2 == 0)
   	
    	
    	for (int i = 1 * 3; i <= 199; Kilo++, i++){
   	        System.out.printf(Kilo + "\t\t  %d5.3f%      " + Kilo * 2.2);
    	}
   }

It's as simple as incrementing by 2

for (int i=1; i<200; i+=2){
    System.out.println(i);
}

The printf documentation isn't the easiest read in the world, but here is how you can limit to 3 decimal places

double d = 4444.3434545;
System.out.printf("%.3f \t\t  %.3f      ", d, d*2.2);

wow i cant believe i didnt see that, thanks alot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.