My assignment is to make an inline function that calculates stock value, it seems to work but when I exit the loop it doesn't show the final value from the accumulator, what is the issue?
#include <iostream>
usingnamespace std;
inlinefloat calculateStockValue(float shares,float price)
{
return shares*price;
}
int main ()
{
char response;
float total=0;
do
{
float shares;
float price;
cout<<"Number of shares of a stock: ";
cin>>shares;
cout<<"Price of the stock: ";
cin>>price;
total = calculateStockValue(shares, price) + total;
cout << "Would you like to enter another stock ? [y/n] ";
cin >> response;
response=tolower(response);
}
while(response=='y');
cout<<"Stock Portfolio Value is "<<total;
return 0;
}