#include %26lt;iostream.h%26gt;
#include %26lt;stdlib.h%26gt;
using namespace std;
int getstockprices;
float printaverage;
float printlowest;
float printhighest;
int main()
{
float stockprice;
float min=0;
float max=0;
float avg=0;
float total =0;
for (int day = 0; day%26lt; 31; day++)
{
void get_stock_price(float %26amp;stockpice);
cout%26lt;%26lt; "Please enter the closing stock price for day"%26lt;%26lt;day+1%26lt;%26lt;":"%26lt;%26lt;endl;
cin%26gt;%26gt;stockprice;
if (stockprice %26gt; max)
max=stockprice;
if (stockprice %26lt; min)
min = stockprice;
else if (day == 0)
min=stockprice;
total += stockprice;
}
cout%26lt;%26lt; "highest Price: "%26lt;%26lt;max%26lt;%26lt;endl;
cout%26lt;%26lt; "Lowest Price: "%26lt;%26lt;min%26lt;%26lt;endl;
cout%26lt;%26lt;"Average price: "%26lt;%26lt;total/31.0%26lt;%26lt;endl;
system("PAUSE");
return 0;
}
i got it working. i get the average, highest lowest, but i have a problem. i am not getting the day the highest was reached. or the day the lowest was reached.
for example when i compile it it should say the lowest stock price occured on day 12 ($64.83)and the lowest occured on
Computer science C++ programing. just a tiny question. plz help?
how many times can u ask this same question this same program? even after people post you fixed code, you post back up the broken code like you did here.
Reply:In the stock-price test conditions set a max / min day variables to the current day when 'true'.
When the loop completes the min / max day variables will hold the corresponding day.
Reply:in this program you dont have code to print the lowest priced occured on day etc..
forsythia
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment