CS 160 - Programming Concepts and Applications

Summer II 2018 - Lab 3E - Multiplication Tables

Quick Links: Canvas | John Cabot | Piazza | zyBooks

|   Home |  Contact |  Syllabus |  Assignments |  Schedule |  Resources   |

This lab is due by Thursday, July 12, 2018, 11:59 PM.

Today we're going to return to our math roots and compute some multiplication tables. First, you must prompt the user to enter two numbers greater than 1 and less than 11. Continue to prompt them until they enter two valid numbers.

To meet the specifications of Part II below, do not give any prompt such as "Enter a number". The user will know to enter a number. But you must ensure the values are within the proper range and continue to receive input until the number is valid.

Then output a multiplication table. You'll need to print out the column and row headers so we know what two values are being multiplied. Then each cell will be the result of that product. Be sure to have the numbers right aligned with enough space to have all our columns aligned.

A sample run of the program is shown below:

112
5
1
7
     1   2   3   4   5   6   7
 1   1   2   3   4   5   6   7
 2   2   4   6   8  10  12  14
 3   3   6   9  12  15  18  21
 4   4   8  12  16  20  24  28
 5   5  10  15  20  25  30  35

Note that the program uses the first two valid values entered as the multipier and multiplicand (5 & 7). When developing your program, you should continually prompt the user until they enter a valid number. Then continually prompt them again until they enter a second valid number.

Hint: You'll need a couple of loops to accomplish this task. And recall, the iomanip library will help you with aligning the columns. The same example from above is shown below, this time with the spaces replaced by x to help you with aligning columns.

112
5
1
7
xxxxx1xxx2xxx3xxx4xxx5xxx6xxx7
x1xxx1xxx2xxx3xxx4xxx5xxx6xxx7
x2xxx2xxx4xxx6xxx8xx10xx12xx14
x3xxx3xxx6xxx9xx12xx15xx18xx21
x4xxx4xxx8xx12xx16xx20xx24xx28
x5xxx5xx10xx15xx20xx25xx30xx35

Recall that the user can enter values within the range 2 to 10 inclusive, so be sure to allocate enough space to handle a 10x10 multiplication table.


Lab Submission



You will submit your solution to this lab with the rest of Set3. Detailed instructions for doing this are posted in Assignment 3.


This lab is due by Thursday, July 12, 2018, 11:59 PM.

Last Updated: 07/04/18 15:55


Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0