Overview
Write a program to calculate the number of singles and total number of bases for a baseball player using information supplied by the player.
If you're not familiar with baseball, keep reading. Otherwise, move ahead to the section titled "Basic Program Logic." A lot of baseball terms are pretty self-explanatory: a single is a 1 base hit, a double is a 2 base hit, and a triple is a 3 base hit. The one that may not be familiar is a home run, which is a 4 base hit.
Basic Program Logic
prompt the player for the total number of hits. This is an integer value that should be stored in an integer variable.
prompt the player for the number of doubles they have hit. This is an integer value that should be stored in an integer variable.
prompt the player for the number of triples they have hit. This is an integer value that should be stored in an integer variable.
prompt the player for the number of home runs they have hit. This is an integer value that should be stored in an integer variable.
calculate the number of singles and the total number of bases the player has earned:
number of singles = total number of hits - number of doubles - number of triples - number of home runs
total number of bases = number of singles + (number of doubles * 2) + (number of triples * 3) + (number of home runs * 4)
display the number of each type of hit (single, double, triple, and home run) with an appropriate label
display the total number of bases with an appropriate label
Here is what I have so far, I know it isn't much but I am very unsure of what I am doing, if someone could explain to me that would be fantastic!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
int s, d, t, h, x, sums;
s = 1;
d = 2;
t = 3;
h = 4;
x = 1;
sums = s + x;
}
|