Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am trying to get started on this lab based on the following i need to write a program; Out 58.0% Walk 9.7% Single 22.0%
I am trying to get started on this lab based on the following i need to write a program;
Out 58.0%
Walk 9.7%
Single 22.0%
Double 6.1%
Triple 2.5%
Home Run 1.7%
Based on the above percentages write a program to simulate stepping up to the plate 1000 times and count and display the number of outs, Walks, Singles and so on, then calculate and display his batting average: the given; batting average = (number of hits) / (Times at bat) - (number of walks)
the following is all have gotten so far;
#include#include //For the square root and pow functions #include//For the time function #include//For setprecision #include//For the rand and srand functions #includeusing namespace std; int main() { //Function prototype void BattingAverage(); //Variables int NumberOfHits; double battingAverage, int TimesAtBat, double NumberOfWalks = 9.7, double singles = 22.0, double doubles = 6.1, double triples = 2.5, double homeRuns = 1.7, double Out = 58.0, double Hits; battingAverage = NumberOfHits / (TimesAtBat) - (NumberOfWalks); Hits = singles + doubles + triples + homeRuns;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started