Question: Deliverable: 1) Name the file containing your C++source code: hw4_xxxxx.cpp; where your own student ID should replace the string xxxxx. Tasks: The aim of this

 Deliverable: 1) Name the file containing your C++source code: hw4_xxxxx.cpp; where

Deliverable: 1) Name the file containing your C++source code: hw4_xxxxx.cpp; where your own student ID should replace the string "xxxxx". Tasks: The aim of this question is to practice the usage of random numbers and arrays in C++. Basically, you are asked to write a C++ program as follows. Declare two arrays of size 5 . One array will store the values of sum of selection and the second one will store the number of selections. Every element in the two arrays is calculated as follows: generate random numbers between 0 and 1 until their sum exceeds 1 , then, store the sum as an element in the first array. The number of generated random numbers for that sum is stored in the second array. For example, if the program generated 0.3,0.57 and 0.45=1.32 which exceeds 1 , then the first element in the first array will be 1.32 (sum of the three random numbers) and the first element in the second array will be 3 (number of generated random numbers until sum exceeds one.). The program will continue until it stores n elements in each array. For every element to be stored in the first array, display the generated random numbers as given in the sample output. Finally, the program displays the output of the two arrays. Figure 1 shows a sample output of the program. Figure 1: Sample Output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!