Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview For this daily, write a function named stats that will test three integer values to determine whether one or more conditions is true. A

Overview
For this daily, write a function named stats that will test three integer values to determine whether one or more
conditions is true.
A CPP file (stats.cpp) has been provided. It contains the prototype statement for the stats function, declaration
for six integer variables (num1, num2, num3, rand_num1, rand_num2, and rand_num3), code that will ask the
user to enter three values, and various calling statements for the stats function.
Add the stats function that is described below to the file. DO NOT change the code that is provided in int main().
void stats( int, int, int )
The stats function tests three integer values to determine whether one or more of the following conditions is
true. The conditions to test are:
1== the first and second numbers are both even.
2== the first number is less than both the second and the third.
3== the second or the third number is odd.
4== either the first or the second numbers are less than the third.
The stats function takes three integer arguments: the three integer values to use in the tests. It returns nothing.
Using the three passed in integers, check the four conditions, and for each condition that is true, print the
corresponding test number followed by a space character.
Print a new line at the beginning and end of the output produced by the function.
For example, if the passed in values are 4,8, and 10, the function should display:
124
since 4 and 8 are both even (condition 1),4 is less than both 8 and 10(condition 2), and 4 or 8 is less than 10
(condition 4). Condition 3 fails because neither 8 nor 10 is odd.
Use the following code to start writing the c++ program: //Compound Relational daily
#include
#include
#include
using namespace std;
//function prototype
void stats(int, int, int);
const int START_TEST =5;
const int NUM_TESTS =3;
int main()
{
int num1, num2, num3;
int rand_num1, rand_num2, rand_num3;
int seed_value;
//Get three numbers to test
cout << "What is the first number? ";
cin >> num1;
cout << "What is the second number? ";
cin >> num2;
cout << "What is the third number? ";
cin >> num3;
cout << endl << "What is the seed value for the random number generator? ";
cin >> seed_value;
//Test the function with user input
cout << endl << "Test 1: check the \'stats\' on the numbers: "<< num1<<","<< num2<<", and "<< num3<< endl;
stats(num1, num2, num3);
//Test the function with known values
cout << endl << "Test 2: check the \'stats\' on the numbers: 1,5, and 9"<< endl;
stats(1,5,9);
cout << endl << "Test 3: check the \'stats\' on the numbers: 6,4, and 6"<< endl;
stats(6,4,6);
cout << endl << "Test 4: check the \'stats\' on the numbers: 9,5, and 1"<< endl;
stats(9,5,1);
//test the function with random values
//seed the random number generator with a value of 15
srand(seed_value);
//conduct the extra tests with the random numbers
for(int testNum = START_TEST; testNum < START_TEST + NUM_TESTS; testNum++)
{
//generate the three random numbers that will be used by the test
rand_num1= rand();
rand_num2= rand();
rand_num3= rand();
//display the heading for the test, including the random n umbers
cout << endl << "Test "<< testNum <<": check the \'stats\' on the numbers: "
<< rand_num1<<","<< rand_num2<<", and "<< rand_num3<< endl;
//determine the stats for the 3 random numbers
stats(rand_num1, rand_num2, rand_num3);
}
return 0;
}
//Code the stats function below this line

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

Students also viewed these Databases questions

Question

Ty e2y Evaluate the integral dy

Answered: 1 week ago