Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program using four enumerators. Initialize each as follows: first, secon

ID: 3778807 • Letter: W

Question

Write a program using four enumerators. Initialize each as follows: first, second, third, fourth, fifth, sixth, seventh, eighth, ninth Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday curve, fast, knuckle, slider single, double, triple, homer The program should prompt a user to input a character array or 4 numbers pertaining to each enumerator. Display help text to assists the user. The help text should display the smallest and largest possible values for each inputted number. Validate the input. Display an error message for a number entered outside the range of the enumerator. Using the enumerators, generate a sentence that will display as follows: In the fifth inning on Saturday, i hit a fast bail for a triple; where (fifth, Saturday, fast and triple) are printed using the input generated from their respective enumerators. The input that produced the statement above would be: 4612 The program should loop allowing the user to decide whether or not he or she wishes to process the loop again.

Explanation / Answer

#include <iostream>
#include <stdlib.h>

using namespace std;

enum Enumerator1
{
FIRST, // assigned 0
SECOND, // assigned 1
THIRD, // assigned 2
FOURTH, // assigned 3
FIFTH, // assigned 4
SIXTH, // assigned 5
SEVENTH, // assigned 6
EIGHTH, // assigned 7
NINTH // assigned 8
};

enum Enumerator2
{
SUNDAY, // assigned 0
MONDAY, // assigned 1
TUESDAY, // assigned 2
WEDNESDAY, // assigned 3
THRUSDAY, // assigned 4
FRIDAY, // assigned 5
SATURDAY // assigned 6
};

enum Enumerator3
{
CURVE, // assigned 0
FAST, // assigned 1
KNUCKLE, // assigned 2
SLIDER // assigned 3
};

enum Enumerator4
{
SINGLE, // assigned 0
DOUBLE, // assigned 1
TRIPLE, // assigned 2
HOMER // assigned 3
};


Enumerator1 printEnumerator1(int n)
{
switch (n) {
case 0 : cout << "first";
break;
case 1 : cout << "second";
break;
case 2 : cout << "third";
break;
case 3 : cout << "fourth";
break;
case 4 : cout << "fifth";
break;
case 5 : cout << "sixth";
break;
case 6 : cout << "seventh";
break;
case 7 : cout << "eighth";
break;
case 8 : cout << "ninth";
break;
}
}

Enumerator2 printEnumerator2(int n)
{
switch (n) {
case 0 : cout << "sunday";
break;
case 1 : cout << "monday";
break;
case 2 : cout << "tuesday";
break;
case 3 : cout << "wednesday";
break;
case 4 : cout << "thrusday";
break;
case 5 : cout << "friday";
break;
case 6 : cout << "saturday";
break;
}
}

Enumerator3 printEnumerator3(int n)
{
switch (n) {
case 0 : cout << "curve";
break;
case 1 : cout << "fast";
break;
case 2 : cout << "knuckle";
break;
case 3 : cout << "slider";
break;
}
}

Enumerator4 printEnumerator4(int n)
{
switch (n) {
case 0 : cout << "single";
break;
case 1 : cout << "double";
break;
case 2 : cout << "triple";
break;
case 3 : cout << "homer";
break;
}
}

int main (){
int s;
cin >> s;
int a,b,c,d, temp;
d = s % 10;
s = s-d;
temp = s % 100 ;
c = temp /10;
s=s-temp;
temp = s % 1000 ;
b = temp /100;
a= s/1000;
if (a>8 || b > 6 || c > 3 || d > 3){
cout << "error";
}
else{
cout << "In the " ;
printEnumerator1(a);
cout << " inning on " ;
printEnumerator2(b);
cout << ", hit a " ;
printEnumerator3(c);
cout << " ball for a " ;
printEnumerator4(d);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote