Question
DESCRIPTION Add code to the spHWfunctions.cpp program that will generate a 10 x 10 multiplication table beginning with integers input by the user. The user
DESCRIPTION
Add code to the spHWfunctions.cpp program that will generate a 10 x 10 multiplication table beginning with integers input by the user.
The user should be prompted for the first of the numbers going across the table as well as the first of the numbers going down the left side of the table using do-while control structure. Do not accept any non-positive integers.
The table should be output to the screen. The table should be easy to read with each column of numbers clearly separate from the others; the table should also have row and column headings.
The program should utilize the while and for control structures and nesting to complete the table. Each iteration of each loop should deal with the output of a single number.
The completed program should contain functions for the following prototypes:
- int promptForColumnStart(); - The function should prompt for the starting column number and validate it. Once it is validated it should return the starting column number.
- int promptForRowStart(); - The function should prompt for the starting row number and validate it. Once it is validated it should return the starting row number.
- int calculateStoppingPoint(int); - The function should return the stopping column or row number.
- int calculateLargestNumber(int, int); - The function should return the largest number that will be in the table.
- int calculateNumberOfDigits(int); - The function should return the number of digits in a given number.
- int calculateColumnWidth(int); - The function should return the column width to be used in the table.
- void makeTable(int, int, int, int, int, int); - The function should display the multiplication table to the screen.
The main() function has been provided. Do not alter any code in function main().
The output of your program should look exactly like this. Data values may differ. |
What number should the columns begin with? 3 What number should the rows begin with? 7
3 4 5 6 7 8 9 10 11 12 -------------------------------------------------- 7| 21 28 35 42 49 56 63 70 77 84 8| 24 32 40 48 56 64 72 80 88 96 9| 27 36 45 54 63 72 81 90 99 108 10| 30 40 50 60 70 80 90 100 110 120 11| 33 44 55 66 77 88 99 110 121 132 12| 36 48 60 72 84 96 108 120 132 144 13| 39 52 65 78 91 104 117 130 143 156 14| 42 56 70 84 98 112 126 140 154 168 15| 45 60 75 90 105 120 135 150 165 180 16| 48 64 80 96 112 128 144 160 176 192 |
The table above would be displayed to the screen.
As another example, if the user enters beginning values of 35 and 21, the following would be displayed to the screen.
35 36 37 38 39 40 41 42 43 44 ------------------------------------------------------------ 21| 735 756 777 798 819 840 861 882 903 924 22| 770 792 814 836 858 880 902 924 946 968 23| 805 828 851 874 897 920 943 966 989 1012 24| 840 864 888 912 936 960 984 1008 1032 1056 25| 875 900 925 950 975 1000 1025 1050 1075 1100 26| 910 936 962 988 1014 1040 1066 1092 1118 1144 27| 945 972 999 1026 1053 1080 1107 1134 1161 1188 28| 980 1008 1036 1064 1092 1120 1148 1176 1204 1232 29| 1015 1044 1073 1102 1131 1160 1189 1218 1247 1276 30| 1050 1080 1110 1140 1170 1200 1230 1260 1290 1320 |
As another example, if the user enters beginning values of 97 and 189, the following would be displayed to the screen.
97 98 99 100 101 102 103 104 105 106 ---------------------------------------------------------------------- 189| 18333 18522 18711 18900 19089 19278 19467 19656 19845 20034 190| 18430 18620 18810 19000 19190 19380 19570 19760 19950 20140 191| 18527 18718 18909 19100 19291 19482 19673 19864 20055 20246 192| 18624 18816 19008 19200 19392 19584 19776 19968 20160 20352 193| 18721 18914 19107 19300 19493 19686 19879 20072 20265 20458 194| 18818 19012 19206 19400 19594 19788 19982 20176 20370 20564 195| 18915 19110 19305 19500 19695 19890 20085 20280 20475 20670 196| 19012 19208 19404 19600 19796 19992 20188 20384 20580 20776 197| 19109 19306 19503 19700 19897 20094 20291 20488 20685 20882 198| 19206 19404 19602 19800 19998 20196 20394 20592 20790 20988 |
Make sure that you add the program comment header and the function prologues to your program before submitting it.
I am learning C++ now and Functions and Value Parameters.
Please do not use difficult code to solve this problem.
Thanks for your helping!
I always give up thumb if it is really helpful to understand it.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started