Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program should be written as one program that has all 8 of the requirememts listed. Coded in C++. Write a program that does the following:
Program should be written as one program that has all 8 of the requirememts listed. Coded in C++.
Write a program that does the following: 1. Read in up to 100 positive non-zero integers. Your input should come from the keyboard, not a file. Your program should not crash if bad data are entered, such as negative numbers, letters, etc. You can use a sentinel value such as zero to indicate the end of your input. 2. Allocate a matrix of n+1x n+1 and arrange the numbers across the top and down the left side, as shown in the diagram below (although it shows them along the bottom.) 3. Allocate a new matrix of exactly the size of your original and copy the original to it. 4. Create a sum grid for one of the matrices and a product grid for the other. That is, for the first one, add, for example, the numbers in position 1, 1 (in the example below assuming that 0,0 is the bottom left) and put the result in the 2,1 position. And so on. 5. In the other matrix, create a product gird using a similar process, except with multiplication. 6. Print both grids neatly and labeled. You can print them one under the other. Use a column width of 7 spaces, and right-justify the numbers. 7. For each grid, determine how many unique sums or products there are and the frequency of each one. For example, in the sum grid shown, there are 7 unique numbers, from 2 to 8. The value 2 occurs once, three occurs twice 8 occurs once. Display this information in a column. Obviously the maximum number of unique sums or products is n^2 (read as n squared,) so allocate a linear array of this size for tracking the counts. You may not need all of it, so keep track of how it has been filled. 8. Return to the start and ask for another set of numbers. Stop if zero is entered for the first number. Lumn Sum Grid Product Grid 4 5 6 7 8 4 8 12 16 4 3 3 4. 5 6 7 3 6 19 9 12 2 3 4 Ch 6 22 6 8. 4 2 . 12 34 5 1 1 3 4 1 23 4 1 2 23 4 For the sum grid you would display the frequencies like this: Value 2 3 count 1 2 3 5 6 1 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