Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use C++. Write a function named rand_mv that generates a random floating-point value. rand_mv should take in a user specified mean and variance. Assume

Please use C++.

Write a function named rand_mv that generates a random floating-point

value. rand_mv should take in a user specified mean and variance. Assume the

corresponding function prototype is

double rand_mv(double mean, double var);

rand_mv() should then calculate A and B, and generate a random value using

randFloat(a,b)

The main function will provide two prompts, the first asking for the desired mean from the

user.

Note: The values denoted as x.xx represent a value of type float in all cases.

It is not a number formatted specifically as X.XX So if the output is 4.99999 it should

remain 4.99999 and not be formatted to look like 4.99

Enter Mean: x.xx

The second prompt will ask for the variance.

Enter Variance x.xx

Finally, in order to know if you have correctly implemented this function your randMV function must output to the terminal the A and B values computed by randMV.

Note: Normally you would not have randMV output these values. This is just so I can test your solution. Even though we are not testing the random value that your function returns, you should still have randMV return this value, since that really is the purpose of this function.

Example: if your randMV function computes the following: A = 2.0 and B = 4.0

We should have output to the terminal as follows:

2.0 4.0

example run:

Enter Mean: 4 0.25 (ENTER) Enter Variance: 3.13397 4.86603 3.71772

Enter Mean: 5 0.65 (ENTER) Enter Variance: 3.60358 6.39642 4.54484

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

More Books

Students also viewed these Databases questions