QuestionQuestion

Write a program to compute various offensive statistics on baseball. The following information will be available on each player:

Number of Walks (BB), Strike Outs (SO), Hit by Pitch (HP), Sac Flys (SF), Singles, Doubles (2B), Triples (3B), and Home Runs (HR) as well as Number of At Bats (AB).

Based on this information, develop a set of functions within your program that will compute the following: Total Bases, Batting Average, Home Run Ratio, Strike Out Ratio, On Base Percentage, and Slugging Average.

You do not need to be a baseball fan to do this ... All the information you need in terms of the formulas and explanations can be found online.

Note: Number of hits is: singles + doubles + triples + home runs

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <cstdlib>
#include <cmath>
#include <iostream>

using namespace std;

// Strikeout Ratio = Number of Strikeouts (divided by) Number of At Bats
double StrikeoutRatio(int strikeouts, int atBats);

// TotalBases = Number of (Singles + [2 x Doubles] +[ 3 x Triples] + [4 x Home Runs])
int TotalBases(int singles, int doubles, int triples, int homerun);

// Batting Average = Hits (divided by) At Bats
double BattingAverage(int hit, int atBats);\

// Home Run Ratio = Number of Home Runs Hit (divided by) Number of At Bats
double HomeRunRatio(int homeruns, int atBats);

// On Base Percentage = (Hits + Walks + Hit-By-Pitch) divided by (At Bats + Walks+ Hit-By-Pitch + Sac Flys)
double OnBasePercentage(int hits, int walks , int hitByPitch, int atBats, int sacFlys);

// Slugging Average =
double SluggingAverage(int singles, int doubles, int triples, int homerun, int atBats);...
$30.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats