C++ Code:
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(0));
//percentages
double out, walk, s, d, t, hr;
out = 58.0;
walk = 9.7;
s = 22.0;
d = 6.1;
t = 2.5;
hr = 1.7;
char choice; //to hold user choice
do{
int atBat = rand()%1000 + 1; //times at bat 1 to 1000 times
//print all counts
cout<<"No. of Outs: "<<(out*atBat)/100<<endl;
cout<<"No. of Walks: "<<(walk*atBat)/100<<endl;
cout<<"No. of Singles: "<<(s*atBat)/100<<endl;
cout<<"No. of Doubles: "<<(d*atBat)/100<<endl;
cout<<"No. of Triples: "<<(t*atBat)/100<<endl;
cout<<"No. of Home Runs: "<<(hr*atBat)/100<<endl;
//calculate batting average
double avg = ((s+d+t+hr)*atBat)/(100*(atBat - (out*atBat)/100));
cout<<"Batting average: "<<avg*100<<endl; //print avg
//get user choice
cout<<endl<<"Do you want to continue? (Y/N): ";
cin>>choice;
}while(choice == 'y'||choice == 'Y');
return 0;
}
OUTPUT:
Using the random dumber library in c++ please help me out with this problem. I am...
I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...
This is for a Unix class. Please help me out. I am attaching a skeletal code of the program below, it just needs ti be filled in. Below is a skeletal code of the program. Fork a child process and then use the parent for reading and the child for writing. This is just a way of sending and receiving messages asynchronously. /* ************************************************************* * Utility functions * ************************************************************** */ static void usageError(const char * progName, const char *msg) {...
Please read case article, "Attention Kmart Shoppers? Into and out of Bankruptcy" and help me come up with a solution for the case as well as action steps to implement the solution! Thank you!! ATTENTION KMART SHOPPERS? Former Kmart CEO, Charles C. Conaway, failed in his 19-month effort to revive the iconic firm, resulting in the largest retailing bankruptcy filing in history on January 22, 2002 (Davies, et al., 2002). On March 11, 2002, bankrupt Kmart named James B. Adamson...
could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...