Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++ 1. Read in up to 100 positive non-zero integers. Your input should come from the keyboard, not a file. Your program should not

in C++ image text in transcribed
image text in transcribed
image text in transcribed
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+1 x 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 bf 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. Sum Grid Product Grid 4 5 6 7 8 4 4 8 12 16 3 4 5 6 7 3 3 6 12 2 3 4 5 6 2 2 9 6 3 4 2 8 1 2 3 4 5 11 4 1 2 3 4. 1 2 3 4 For the sum grid you would display the frequencies like this: Value 2 3 4 5 Count 1 2 3 4 6 7 8 3 2 1 40 35 Grading criteria: Program runs correctly for good data and rejects bad data, as explained above Program is structured well, using functions as needed rather than in-line code Program uses dynamic arrays for the matrices Program comments and variable names. Make sure you have both header comments and internal comments as needed. 15 10 Using vectors: -30 Using an array of pointers to arrays (this is extremely inefficient in terms of both memory and time) - 10 No error checking: -10 Not freeing the arrays once you're done: -5 Doing everything in the "main" method: -10 or more

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

How to reverse a Armstrong number by using double linked list ?

Answered: 1 week ago