程序代写代做代考 c++ EGR 126

EGR 126
Program 8 – Dot Product
The objective of this Program is to gain experience using nested loops and arrays in a program by reading, storing and processing data from a file.
Design a C++ program to calculate the dot product of two arrays.
The program should process several sets of data from one file.
The program should be general enough to process a different number of data sets each time it is run, so the number of data sets to be processed is an entry in the file.
For each data set, your program should do the following:
1) Use a loop structure to read the data from a file and store it in two different arrays.
2) Once all the data has been read in, use a second loop to find the dot product of the two arrays. For example, the dot product of two arrays, x and y, with 3 elements each wouldbe
𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑=𝑥𝑥 ∗𝑦𝑦 +𝑥𝑥 ∗𝑦𝑦 +𝑥𝑥 ∗𝑦𝑦 001122
3) Print out the array values, with two decimal places, side by side, including the element number, and then print out the dot product value. Label the information clearly.
For example, a data set consisting of 2 arrays of 4 elements each could be arranged in a file like this:
41.0 2.0 3.0 0.0 2.0 4.0 6.0 8.5
The printout for this data set would look something like the following.
Element 0
1 2 3
Array 1 1.0
2.0 3.0 0.0
Array 2 2.0
4.0 6.0 8.5
The dot product of the two arrays is 28.0.
You should not need more than two arrays. Process each data set before you read in the next data set. You may assume there are never more than 50 elements in any array. You may choose to include functions in the program, but that is not a requirement.
Test your program with the datafile Prog8data.txt available in Canvas.
The data file contains 5 lines of text at the beginning describing how the file is set up.
Be sure to read, and print these lines of text, as well as the filename. Please do not alter the contents or arrangement of this file.
Use standard programming practices, including good use of variable names and good comments.
Updated 8/29/2016 Page 1 of 2

EGR 126
This is a copy of the data file provided for you in Canvas:
Updated 8/29/2016 Page 2 of 2