Question: Please read the directions and please put comments through the program. The attached C++ program is what I was given and is the program I






Please read the directions and please put comments through the program. The attached C++ program is what I was given and is the program I need to edit
Objectives: The main objective of this assignment is to help you review some of the concepts related to functions in C++. General Instructions: 1. Read the Background and Task Description below. 2. In this assignment, you will be given a working program. 3. Split the main function given into multiple functions. Task Description: You have been given a very simple program that performs basic operations (addition, subtraction, editing) on two randomly generated integer vectors. All functionality has been included in main, causing code segments to be repeated as well as diminishing the readability. Rewrite the program by grouping calculations and related operations into functions. In particular, your program should include the following functions. - Initializelectors: This is a void function that initializes the two vectors by random numbers. Inside this function, the user will be prompted to enter the maximum random number. After the vectors have been populated with random numbers, print the vectors side by side. The parameters are the two arrays and their size. - EditVector: This is a void function that allows the user to update a value belonging to either vector. The user specifies the vector he wants to edit, the index he wants edit, and finally the updated value. The entire vector must then be printed on the screen. You need to pass the two arrays and their sizes. - CalculateAverage: This is a function that returns the average value in a vector. It returns a double and receives as parameters an array and its size. - printlector: A void function that takes a vector as a parameter along with its size, and prints it on the screen. As you introduce each function, replace the code in main(.) by the appropriate function call. Also, keep in mind that for some functions, any changes that occur within the function body must also be visible in main. Finally, some functions can be called within other functions. Remember that this program was already working. You should not alter the code you just need to restructure it. By the end of this assignment, the program's structure and functionality will be more transparent, making it both easier and faster to understand. Submission notes for Task: - Zip the entire Cade: Blocks project containing all the . cod . h, . cha files and name the zipped file "Assg0_cslogin.zip", where the aslagia is your login ID for the computers at the Department of Computer Science at ODU. Submission with a different file name other than Assg0_cslogin will receive 10 points off your final points for the assignment. - Submit the zipped file using the appropriate Blackboard link. - Using global variables will cause a 10 point deduction to your final score. Suggested Input: Sample Output: Vector Addition: Enter Action: vector addition( (0), vector subtraction(1), average(2), edit(3), print vectors(4), 20 Vector Subtraction: Enter Action: vector addition(0), vector subtraction(1), average(2), edit(3), print vectors(4), clear screen(5), exit(-1):1 2 0 5 0 1 Enter Action: vector addition(0), vector subtraction(1), average(2), edit(3), print vectors(4), clear screen(5), exit(-1): Two consecutive Average Calculations: Requested vector 1 average first, then the same for vector 2. Enter Action: vector addition(0), vector subtraction(1), average(2), edit(3), print vectors(4), clear screen(5), exit(-1):2 Average of Vector 1 , or Vector 2 (Enter 1 or 2 )? Average:9.6 Enter Action: vector addition(0), vector subtraction(1), average(2), edit(3), print vectors(4), clear screen(5), exit(-1):2 Average of Vector 1 , or Vector 2 (Enter 1 or 2)? Average: 8.8 Enter Action: vector addition(0), vector subtraction(1), average(2), edit(3), print vectors(4), clear screen(5), exit(-1): Print Vectors: Enter Action: vector addition(0), vector subtraction(1), average(2), edit(3), print vectors(4), clear screen(5), exit(-1):4 91161111111111110 Enter Action: vector addition(0), vector subtraction(1), average(2), edit(3), print vectors(4), clear screen(5), exit(-1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
