cs175:loops_lab_-_inches_to_centimeters_conversion_table
US2Metric
- Topics: Loops, using the counter variable
Write and save a program US2Metric that prints inches-to-centimeters and pounds-to-kilograms conversion tables, side by side.
The table will range from 1-50 inches and pounds. Since we know the number of repetitions that are needed, a for loop is suitable here.
In for loops, the counter variable (which is often int i) can sometimes be used in the body of the loop.
In this example, the for loop counter variable i will be used to represent the range of values for inches and pounds, and i will also be used in the calculation of the centimeters and kilograms equivalent values.
Sample output:
inches centimeters pounds kilograms ------ ----------- ------ --------- 1 2.54 1 0.45359237 ... ...
cs175/loops_lab_-_inches_to_centimeters_conversion_table.txt · Last modified: 2015/11/24 19:25 by jchung