Source Code
Here is some source code I have written for a program to calculate a person's slugging percentage.
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
//mark wyles
//program calculates the slugging percentage
//2/21/02
int main()
{
int s,d,t,h,atbats;
double percentage;
cout<<"Enter the number of singles: ";
cin>>s;
cout<<"Enter the number of doubles: ";
cin>>d;
cout<<"Enter the number of triples: ";
cin>>t;
cout<<"Enter the number of Home Runs: ";
cin>>h;
cout<<"Enter the number at bats: ";
cin>>atbats;
percentage=(s+2*d+3*t+4*h)/((double)atbats);
cout<<endl;
cout<<"Slugging Percentage:
"<<setprecision(3)<<percentage<<endl;
return 0;
}