Completely confused on why my C++ code isn't calculating the right result

The question is

Program Specifications Your program will do the following:

Prompt for three values with the following units:
a. Integer: heart beats in heartbeats per minute.

b. Integer: left ventricle stroke volume in milliliters (average human does about 50 mls/stroke). This is how much blood is moved on each heartbeat.

c. Integers: average lifetime in years

Print the following results:
a. Float: total heart beats in the provided lifetime

b. Float: total blood moved in gallons (look up the conversion) in the provided lifetime

c. Use the Sample to set output format

Prompt for the following value:
a. Integer: Target lifespan you would like to achieve as a human being.

Print the following results:
a. Float: assuming you live for 2x109 heartbeats, what is your target heart rate to achieve your target lifespan

b. Use the Sample to set output format



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
int main(){

long heartbeat = 0;
long averagelife = 0;
long volume = 0;

cout << "Enter the heart rate (bps): ";
cin >> heartbeat;
cout << "Enter the stroke volume(mls): ";
cin >> volume;
cout << "Lifetime in years: ";
cin >> averagelife;

cout << "Results " << endl;

double totalbeats = heartbeat * volume;
double volumeG = volume/3785.41178;

cout << scientific << setprecision(4) << "Total beats: " << totalbeats << endl;
cout << scientific << setprecision(4) << "Total volume(Gallons): " << volumeG << endl;

long targetage = 0;
cout << "What's your target age: ";
cin >> targetage;


cout << "Your resting heartbeat should be: ";  
}




When I enter the values in order: 60 50 70

I don't get the right numbers. Can someone tell me why? I am suppose to get 2.2075e+09 2.9158e+07

But if you run my code I don't get those results^ Can someone please tell me why? I've been doing this for 4+ hours. Thanks
60 * 50 = 30000e+03
50 / 3785.41178 = 1.3209e-02

I don't see how you're supposed to get the numbers you gave. Perhaps something wrong with the formula? Because the calculation C++ does is top notch.
Topic archived. No new replies allowed.