java - Print an array using a method that has a loop -


i need print array using loop inside method. code works 1 number. need print array x increasing 1 , y increasing 5.
code should this

feet  meters |  meters    feet  1.0  0.305   |  20.0    65.574 2.0  0.610   |  25.0    81.967 ...     9.0  2.745   |  60.0    196.721 10.0  3.050  |  65.0    213.115 

this code

    double x = 1.0;     double y = 20.0;      double k = foottometer(x);//gets foottometer     double m = metertofoot(y);     system.out.print("feet\tmeters\t|   meters\tfeet");     system.out.printf("\n%.1f\t%.3f\t|   %.1f\t%.3f",x,k,y,m); }//close main  public static double foottometer(double foot) {     double meter = 0.0;     (int i=0; i<10; i++) {         meter = 0.305 * foot;     }     foot++;     return meter;   }//close foottometer  public static double metertofoot(double meter) {     double foot = 0.0;     (int i=0; i<65; i++) {         foot = 3.279 * meter;     }     meter++;      return foot; }//close metertofoot 

as mentioned in comment answer, please check if loops located @ right place.

from problem description , code try solution this:

... double x = 1.0; double y = 20.0; double k; double m;  system.out.print("feet\tmeters\t|   meters\tfeet");  (int i=0; i<10; i++) {   k = foottometer(x);   m = metertofoot(y);    system.out.printf("\n%.1f\t%.3f\t|   %.1f\t%.3f",x,k,y,m);   x = x+1;   y = y+5;  } }  public static double foottometer(double foot) {  return 0.305 * foot; }  public static double metertofoot(double meter) {  return 3.279 * meter; } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -