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

Write a program using CASE \"SWITCH\" STATEMENTS for four enumerators. Initializ

ID: 3539132 • Letter: W

Question

Write a program using CASE "SWITCH" STATEMENTS for 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.

Explanation / Answer

#include<iostream>

#include<string>

using namespace std;

enum inning{first,second,third,fourth,fifth,sixth,seventh,eighth,ninth};

enum dayTime{Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};

enum ballType{curve, fast, knuckle, slider};

enum scoring{single,Double,triple,homer};

int main()

{

int a,b,c,d;

string msg;

cout<<"enter 4 number seperated by space the range of these number are ";

cout<<"first number 0 to 8 second number 0 to 6";

cout<<" third number 0 to 3 forth number 0 to 3 ";

do{

cin>>a>>b>>c>>d;

if(a<0||b<0||c<0||d<0||a>8||b>6||c>3||d>3)

cout<<"enter value is out of range reenter values ";

}

while(a<0||b<0||c<0||d<0||a>8||b>6||c>3||d>3);

msg = "in the ";

switch(a)

{

case first:

msg+="first";

break;

case second:

msg+="second";

break;

case third:

msg+="third";

break;

case fourth:

msg+="fourth";

break;

case fifth:

msg+="fifth";

break;

case sixth:

msg+="sixth";

break;

case seventh:

msg+="seventh";

break;

case eighth:

msg+="eighth";

break;

case ninth:

msg+="ninth";

break;

}

msg+=" inning on ";

switch(b)

{

case Sunday:

msg+="sunday";

break;

case Monday:

msg+="monday";

break;

case Tuesday:

msg+="tuesday";

break;

case Wednesday:

msg+="wednesday";

break;

case Thursday:

msg+="thursday";

break;

case Friday:

msg+="friday";

break;

case Saturday:

msg+="saturday";

break;

}

msg+=", I hit a ";

switch(c)

{

case fast:

msg+="fast";

break;

case curve:

msg+="curve";

break;

case knuckle:

msg+="knuckle";

break;

case slider:

msg+="slider";

break;

}

msg+=" ball for a ";

switch(d)

{

case single:

msg+="single";

break;

case Double:

msg+="double";

break;

case triple:

msg+="triple";

break;

case homer:

msg+="homer";

break;

}

msg+=". ";

cout<<msg;

return 0;

}

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