CSCI 261 - Programming Concepts (C++)

Summer 2018 - Lab 4B - Multiplication Tables

Quick Links: Canvas | CS @ Mines | Piazza | zyBooks

|   Home |  Contact |  Syllabus |  Assignments |  Schedule |  Resources   |
This lab is due by Thursday, May 24, 2018, 11:59 PM.


Part I - Development



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.


Part II - Testing



To ensure your program meets the required specifications, log into the AutoGrader - which must be accessed from the Mines network (so you'll need to use the VPN if at home). Log in with your multipass account. Navigate to our course, Lab4B, multiplyTables. You will see on the right hand side a text editor. Enter your code here. Then hit the "Test" button in the lower left corner.

You'll see a colored bar at the top with each segment denoting a single test. Each test provides a specific input to your program and then compares your output with the expected output. If the bar is green, then the test passed. If the bar is red, then the test failed and you can compare your output with the expected output by hovering over the box. Additionally, if your code has a compiler error it will display the error. Note: the most likely cause for your test not matching is the spacing not being correct. The output does not give the best alignment for the columns, but between all the tests you can deduce where your spacing is off.

Once you have passed all of the tests, press the save icon in the text editor to save your code and then hit the "Submit" button to submit all your tests for grading. You must perform these TWO steps to receive full credit for this lab.

You must press "Save" in AutoGrader and "Submit" with all tests passed to receive full credit for this lab.


Lab Submission



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


This lab is due by Thursday, May 24, 2018, 11:59 PM.

Last Updated: 05/25/18 10:38


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