5.3 (Conversion from kilograms to pounds) Write a program that displays the following
table (note that 1 kilogram is 2.2 pounds):
Kilograms Pounds
1 2.2
3 6.6
...
197 433.4
199 437.8
Kilograms Pounds
1 2.2
3 6.6
...
197 433.4
199 437.8
public class ProgrammingEx5_3 { public static void main(String[] args) { final int END = 199; //printing table header System.out.printf("%9s%15s\n","Kilograms","Pounds"); for(int i=1; i<=END;i++ ){ System.out.printf("%-9d%15.1f\n",i,i*2.2); } } }
No comments :
Post a Comment