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: 1. first, se

ID: 3764304 • Letter: W

Question

Write a program using four enumerators. Initialize each as follows: 1. first, second, third, fourth, fifth, sixth, seventh, eighth, ninth 2. Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday 3. curve, fast, knuckle, slider 4. 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 ball 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. This is C++ code(language)

Explanation / Answer

If you have any further queries, just get back to me.

#include <iostream>
using namespace std;
int main()
{
enum number {first = 1, second, third, fourth, fifth, sixth, seventh, eighth, ninth};
enum week {Sunday = 1, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};
enum ballType   {Curve = 1, Fast, Knuckle, Slider};
enum runs {Single = 1, Double, Triple, Homer};
int n;
cout<<"Enter the position (Between 1 and 9): ";
cin>>n;
number num = static_cast <number>(n);
cout<<"Enter the week day (Between 1 and 7): ";
cin>>n;
week day = static_cast <week>(n);
cout<<"Enter the ball type (Between 1 and 4): ";
cin>>n;
ballType ball = static_cast <ballType>(n);
cout<<"Enter the number of runs (Between 1 and 4): ";
cin>>n;
runs run = static_cast <runs>(n);
cout<<"In the ";
if(num == first)
cout<<"FIRST ";
else if(num == second)
cout<<"SECOND ";
else if(num == third)
cout<<"THIRD ";
else if(num == fourth)
cout<<"FOURTH ";
else if(num == fifth)
cout<<"FIFTH ";
else if(num == sixth)
cout<<"SIXTH ";
else if(num == seventh)
cout<<"SEVENTH ";
else if(num == eighth)
cout<<"EIGHTH ";
else if(num == ninth)
cout<<"NINTH ";
cout<<"innings on ";
if(day == Sunday)
cout<<"Sunday ";
else if(day == Monday)
cout<<"Monday ";
else if(day == Tuesday)
cout<<"Tuesday ";
else if(day == Wednesday)
cout<<"Wednesday ";
else if(day == Thursday)
cout<<"Thursday ";
else if(day == Friday)
cout<<"Friday ";
else if(day == Saturday)
cout<<"Saturday ";
cout<<", I hit a ";
if(ball == Curve)
cout<<"curve ";
else if(ball == Fast)
cout<<"fast ";
else if(ball == Knuckle)
cout<<"knuckle ";
else if(ball == Slider)
cout<<"slider ";
cout<<"ball for a ";
if(run == Single)
cout<<"single."<<endl;
else if(run == Double)
cout<<"double."<<endl;
else if(run == Triple)
cout<<"triple."<<endl;
else if(run == Homer)
cout<<"homer."<<endl;   
}

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