loops :: problem set 1

  1. Write a program which will output the cubes of numbers from 1 to 12

    Your output should look like this:

    The cube of 1 is 1
    The cube of 2 is 8
    The cube of 3 is 27
    .
    .
    The cube of 12 is 1728

  2. Write a program that will ask the user to enter a number. The program then generates the number's multiplication table from 1 to 12

    Your output should look like this:

    THE MULTIPLICATION TABLE OF 12

    1 x 5 = 5
    2 x 5 = 10
    .
    .
    12 x 5 = 60

  3. Write a program which will display a conversion table from miles to kilometers ( 1 mile = 1.6 km). Design the program so that the values for miles increases by five. The table will start with 5 miles and end with 100 miles.

    Your output should look like this:

    MILES          KILOMETERS

    5                 8
    10               16
    15               24
    .
    .
    100             160

  4. Modify the last program so it will allow the user to specify the starting and ending values but not the increment

  5. Write a program which outputs the decimal equivalent values of the fractions 1/2 to 1/10

    Your output should look like this:

    The decimal equivalent of 1/2 is .500
    The decimal equivalent of 1/3 is .333
    The decimal equivalent of 1/4 is .250
    .
    .
    The decimal equivalent of 1/10 is .100

  6. Write the class Stopped that obtains a number from the user and counts backwards from 100 by 5's, outputting "I stopped" when the count would be less than the number specified by the user, sample:

    What number do I stop at? 82
    100
    95
    90
    5
    I stopped.

For answers click here