Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a baseball lineup for a PONY baseball team User Requirements A manager of a PONY ( Protect Our Nation s Youth ) baseball team

Create a baseball lineup for a PONY baseball team
User Requirements
A manager of a PONY (Protect Our Nations Youth) baseball team has hired you to design a program that creates a
baseball lineup and position assignment. The lineup (i.e., the batting order from 1st to last) will be based on the batting
average of each player. For example, if Joshua has an average of 692 and Jackson has an average of 459, Joshua will be
placed first in the lineup, followed by Jackson.
In terms of the position assignment (i.e., Joshua plays 1st base in inning 1,3rd base in inning 2, center field in inning 3,
etc.) your program must assign the field positions for each defensive player in accordance to the PONY Shetland rules
stated below.
1. The line-up should include batting order and players defensive positions for each of the five innings.
2. Each team shall play all players in the field in defensive positions. Additional players, (short fielders), shall be
positioned in the outfield no closer than 20 feet to the baseline when the ball is hit and will be considered
outfielders.
3. Each player must be scheduled to play an infield position at least one (1) inning. Catcher will be considered an
infield position. A player may only be scheduled to play catcher a maximum of one (1) inning per game. No
player may play a second inning of infield until every other player has played one inning of infield.
4. A player cannot play the same defensive position for more than one (1) inning per game.
5. A player can only sit out one (1) inning per game.
Software Requirements
- Create a flowchart or pseudo code to establish an algorithm of how to solve this problem.
- Use a two dimensional string array to store the lineup player names and position assignments for each player as seen
above.
- You can use an iterative approach to display the array, but if you are going to use a recursive approach, use a recursive
function to display the names and positions of the lineup and field positions. This recursive function must be a void
function called displayArray that receives a 2D array, a first index whole number, and a last index whole number. The
void function must use the divide-and-conquer approach as described in your text.
- You are permitted to create any additional arrays, variables, functions, etc. towards the completion of this project.
Has to contain the 'main' function. Program execution begins and
ends there.
//
#include
#include
using namespace std;
struct player {
string name;
int average;
};
const int TEAM_SIZE =12;
const int NUM_INNINGS =5;
void displayArray(string innings[TEAM_SIZE][NUM_INNINGS +1]);
int main()
{
// Declarations
player players[TEAM_SIZE];
// Get user input
cout "Enter 12 player names: " endl;
for (int i =0; i TEAM_SIZE; i++){
cout "What is player " i +1"'s name: ";
cin >> players[i].name;
}
cout "Enter the average for each player: " endl;
cout "__________________________________" endl;
for (int i =0; i TEAM_SIZE; i++){
cout "What is " players[i].name "'s average: ";
cin >> players[i].average;
}
// The string array used to store the lineup of
// player names and player position assignment
string innings[TEAM_SIZE][NUM_INNINGS +1]={{}};
// Calculate positions
// Display result
displayArray(innings);
system("pause");
return 0;
}
void displayArray(string innings[TEAM_SIZE][NUM_INNINGS +1]){
cout "Game lineup and field positions:" endl;
cout "________________________________" endl;
cout "Name \t Inning 1\t Inning 2\t Inning 3\t Inning 4\t Inning 5"
endl;
for (int i =0; i TEAM_SIZE; i++){
for (int j =0; j NUM_INNINGS +1; j++){
printf("%-15s", innings[i][j].c_str());
}
printf("
");
}
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Bioinformatics Databases And Systems

Authors: Stanley I. Letovsky

1st Edition

1475784058, 978-1475784053

More Books

Students also viewed these Databases questions

Question

4. Does cultural aptitude impact ones emotional intelligence?

Answered: 1 week ago