
Patrick B. answered 02/25/20
Math and computer tutor/teacher
using namespace std;
#include <iostream>
int GO()
{
int X,Y,Z;
char operation;
cout << " Please input the first # :>";
cin >> X;
cout << "Please input the 2nd # :>";
cin >> Y;
cout << "Please input the 3rd # :>";
cin >> Z;
cout << "Please input the operation :>";
cin >> operation;
switch (operation)
{
case 'A':
case 'a':
{
int total = X+Y+Z;
int remainder = total %3;
int n = total/3;
cout << " The average is " << n;
if (remainder==0)
{
cout << endl;
}
else
{
cout << " and " << remainder << "/3" << endl;
}
break;
} //A , a
case 'M':
{
int temp = (X>Y) ? X : Y;
int maxInt = ( temp > Z) ? temp : Z;
cout << " The max is " << maxInt << endl;
break;
} //M
case 'C':
case 'c':
{
int A[3];
A[0]=X;
A[1]=Y;
A[2]=Z;
//bubble sort
if (A[0]>A[1])
{
int temp = A[1];
A[1] = A[0];
A[0] = temp;
}
if (A[1]>A[2])
{
int temp = A[1];
A[1] = A[2];
A[2] = temp;
}
if (A[0]>A[1])
{
int temp = A[1];
A[1] = A[0];
A[0] = temp;
}
cout << " sorted... "<< endl;
for (int iLoop=0; iLoop<3; iLoop++)
{
cout << A[iLoop]<< endl;
}
cout << "The middle # is " << A[1] << endl;
break;
} //C,c
case 'O':
case 'o':
{
int even_count = 0;
if ((X%2)==0)
{
cout << X << " is even " << endl;
even_count++;
}
if ((Y%2)==0)
{
cout << Y << " is even " << endl;
even_count++;
}
if ((Z%2)==0)
{
cout << Z << " is even " << endl;
even_count++;
}
cout << even_count << " of the 3 integers are even " << endl;
break;
} //O,o
case 'P':
case 'p':
{
if (
((X%2)==0) && ((X%3)==0) && ((X%5)==0)
)
{
cout << X << " is divisible by 2, 3, and 5 " << endl;
}
if (
((Y%2)==0) && ((Y%3)==0) && ((Y%5)==0)
)
{
cout << Y << " is divisible by 2, 3, and 5 " << endl;
}
if (
((Z%2)==0) && ((Z%3)==0) && ((Z%5)==0)
)
{
cout << Z << " is divisible by 2, 3, and 5 " << endl;
}
break;
} //P,p
case 'E':
case 'e':
{
if ((X==Y) && (Y==Z))
{
cout << " The three integers are equal " << endl;
}
else
{
if ((X==Y) || (Y==Z) || (X==Z))
{
cout << " Two of the three integers are equal " << endl;
}
else
{
cout << " The three integers are different " << endl;
}
}
break;
} //'E','e'
case 'S':
case 's':
{
if (
((X+Y)==Z) ||
((X+Z)==Y) ||
((Y+Z)==X)
)
{
cout << " One of the integers is a sum of the other two " << endl;
}
else
{
cout << " None of the integers is the sum of the other two " << endl;
}
break;
} //S,s
case 'm':
{
int N = X+1;
int sum = 0;
do
{
sum += N;
N += Z;
} while (N<Y);
cout << " The sum of the integers between " << X << " and " << Y << " that differ by " << Z << " is " << sum << endl;
break;
}
} //m
return 0;
}
int main()
{
return(GO());
}