Question
The following C++ main driver makes use of a C++ structure Cint that models closed number intervals on the real line. Math review: The closed
The following C++ main driver makes use of a C++ structure Cint that models closed number intervals on the real line. Math review: The closed number interval [a,b] = {x | a < x < b}.
Write the C++ definitions of the structure Cint and the functions readCint, dispCint, midpt, upperInt, inIt that manipulate closed intervals in this driver.
See the sample run of this driver, below, to see the output generated.
int main()
{
Cint I,IU;
float x;
I = readCint();
cout << "Interval = ";
dispCint(I);
cout << "Interval midpoint = " << midpt(I) << endl;
IU = upperInt(I);
cout << "Upper half interval = ";
dispCint(IU);
cout << "Enter a number: ";
cin >> x;
if (inIt(x,I))
cout << x << " is in the interval ";
else
cout << x << " is not in the interval ";
dispCint(I);
return 0;
}
Here is output from a sample run of the program (user input in bold):
Enter lower limit: 2
Enter upper limit: 8
Interval = [2,8]
Interval midpoint = 5
Upper half interval = [5,8]
Enter a number: 9
9 is not in the interval [2,8]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started