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) {
    	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);
9 Years
Discussion Span
Last Post by Andrewsc1

It's as simple as incrementing by 2

for (int i=1; i<200; i+=2){

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);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.