1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include "Middle.h"
int main()
{
int user_input1, a, b, c, i, j, k;
double user_input2, d, e, f;
char user_input3, x, y, z;
cout << "Enter 3 integers: ";
for(i = 1; i <= 3; i++)
{
while (!(cin >> user_input1)) // While we have an error reading...
{
cin.clear(); // Remove the error state in stream
cin.ignore(); // Read but ignore the next character
}
if(i == 1)
{
a = user_input1;
}
if(i == 2)
{
b = user_input1;
}
if(i == 3)
{
c = user_input1;
}
}
cout << "The middle value of " << a << ", " << b << ", and " << c << " is " << doMid(a,b,c) << endl << endl
<< "Enter 3 floating point values: ";
for(j = 1; j <= 3; j++)
{
while (!(cin >> user_input2))
{
cin.clear();
cin.ignore();
}
if(j == 1)
{
d = user_input2;
}
if(j == 2)
{
e = user_input2;
}
if(j == 3)
{
f = user_input2;
}
}
cout << "The middle value of " << d << ", " << e << ", and " << f << " is " << doMid(d,e,f) << endl << endl
<< "Enter 3 characters: ";
for(k = 1; k <= 3; k++)
{
while (!(cin >> user_input3))
{
cin.clear();
cin.ignore();
}
if(k == 1)
{
x = user_input3;
}
if(k == 2)
{
y = user_input3;
}
if(k == 3)
{
z = user_input3;
}
}
cout << "The middle value of " << x << ", " << y << ", and " << z << " is " << doMid(x,y,z) << endl;
}
|