Advertisement
PadmaJS

Exercise 5.9

Sep 30th, 2022
2,762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.62 KB | None | 0 0
  1. class Exercise5_9 {
  2.   public static double footToMeter(double foot) {
  3.     return 0.305 * foot;
  4.   }
  5.  
  6.   public static double meterToFoot(double meter) {
  7.     return 3.279 * meter;
  8.   }
  9.  
  10.   public static void main(String[] args) {
  11.  
  12.     System.out.println("Feet      Meters     |   Meters       Feet");
  13.     System.out.println("---------------------------------------------");
  14.     for (double i = 0; i < 10; i++) {
  15.       double meters = footToMeter((i + 1));
  16.       double feet = meterToFoot((20 + i * 5));
  17.       System.out.printf(" %.1f      %.3f      |    %.1f       %.3f\n", (i + 1), meters, (20 + i * 5), feet);
  18.     }
  19.   }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement