Question: Write a program that declares three pointers for three one-dimensional arrays named price, quantity, and amount. Each array should be declared in main(). The size
Write a program that declares three pointers for three one-dimensional arrays named price, quantity, and amount. Each array should be declared in main(). The size of the arrays should be asked from user. Trycatch blocks are to be used for handling exceptions such as "RUNTIME ERROR: The program failed to allocated negative memory if the size entered is negative.
The three arrays should be created dynamically using new operator and their memory should be released by using the delete operator. The price and quantity values should be between 0.0 and 100.0 and the same should be validated by using functions contained in MyConsoleInput.h. The values should be stored in arrays using pointer notation.
Have your program pass these three arrays and size of amount array to a function called Extend(), which calculates the elements in the amount array as the product of the equivalent elements in the price and quantity arrays: for example, amount[1] = price[1] * quantity[1]. The function declaration using pointers can be void Extend (double *, double *, double *, int);
The extend function should be called only if the number of elements of price and quantity match otherwise it should throw an error saying Please enter the same elements of price and quantity to calculate amount. After Extend () has put values in the amount array, display the values in the array from within main().
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
