# Format Problems

• October 27th, 2010, 07:55 PM
maximus20895
Format Problems
I am trying to make it say feet meters meters feet, but instead it just says feet meters then enters the data and then starts the meter to feet. There are only two columns and I am trying to have four.

I have to keep both methods and I just can't figure it out :( I know you can do a for loop within a for loop, but I can't get that to work either.

Code Java:

```public static void main(String[] args) { // Assign Variables double meter = 0; double foot = 0; double x; double y;   //Header for meters to foot System.out.println(" Feet Meters");   //for loop to call meter method and print out table   for(x = 1; x <=10; x++) { meter = footToMeter(x); System.out.printf("%5.1f%20.3f" , x, meter); System.out.println(); }   //Header for foot to meters System.out.println("Meters Feet");   //for loop to call foot method and print out table for(y = 20; y <= 65; y = y+5) { foot = meterToFoot(y); System.out.printf("%5.1f%20.3f" , y, foot); System.out.println(); } }   //Converts from feet to meters   public static double footToMeter(double foot) { return 0.305 * foot; }   //Converts from meters to feet public static double meterToFoot(double meter) { return 3.281 * meter; } }```
• October 27th, 2010, 09:48 PM
American
Re: Format Problems
Code Java:

```public static void main(String[] args) { // Assign Variables double meter = 0; double foot = 0; double x; double y;   //Header for meters to foot System.out.println(" Feet Meters | Meters Feet"); System.out.println("----------------------------------------------------");   //for loop to call meter method and print out table String formater = "%5.1f%20.3f |%5.1f%20.3f"; for(x = 1; x <=10; x++) { meter = footToMeter(x); y= 25+5*x; foot = meterToFoot(y); System.out.printf(formater, x, meter, y, foot); System.out.println(); }     }   //Converts from feet to meters   public static double footToMeter(double foot) { return 0.305 * foot; }   //Converts from meters to feet public static double meterToFoot(double meter) { return 3.281 * meter; }```