#include %26lt;iostream.h%26gt;
#include %26lt;stdlib.h%26gt;
using namespace std;
int getstockprices;
float printAverage;
float printLowest;
float printhighest;
int main()
{
int stockprice;
float average;
float lowest;
float highest;
void get_stock_price(float %26amp;stockprice)
cout%26lt;%26lt;"Please enter the closing stock price for day 1."%26lt;%26lt; endl;
cin%26gt;%26gt; stockprice;
int day;
for(day = 0; day %26lt; 31; day++)
{
float stockprice;
float getstockprice(stockprice);
cout %26lt;%26lt; "1st price: " %26lt;%26lt; stockprice %26lt;%26lt; endl;
if (min%26gt;current entered price)
mine=currententeredprice;
min_day=day;
if (mas %26lt; current entered price)
max=current entered price;
max_day=day;
system("PAUSE");
return 0;
}
what am i doing wrong i don't understand. please help.
write compile and run a C++ program with proper style and function to read 31 days worth of closing stock prices from a user. after accepting 31days worth of stock prices the program will output:
highest price
lowest price
average price
C++ programing. computer science. please helpppp?
//I'm not completing this code for you...just bringing you a little closer to home...
using namespace std;
//Kill all these unused variables...(i think you were planning
//on making these functions maybe?
//int getstockprices;
//float printAverage;
//float printLowest;
//float printhighest;
//Put function definitions Outside of main()!
void get_stock_price(float %26amp;stockprice)
{
cout%26lt;%26lt;"Please enter the closing stock price: " ;
cin%26gt;%26gt; stockprice;
}
int main()
{
///Next to variable have the same name...that won't work.
//Let's kill the integer version
float stockprice;
//int stockprice;
float average;
float lowest;
float highest;
int day;
for(day = 0; day %26lt; 31; day++)
{
getstockprice(stockprice);
cout %26lt;%26lt; "1st price: " %26lt;%26lt; stockprice %26lt;%26lt; endl;
}
////ALSO I think you need to use well-placed curly braces
//maybe like so...
if (min%26gt;current entered price)
{
mine=currententeredprice;
min_day=day;
}
///I'm seeing a few undeclared variables above
//and below...that won't compile
///also spaces aren't allowed in variables
//"current entered price" ????
//try instead: "current_entered_price"
if (mas %26lt; current entered price)
{
max=current entered price;
max_day=day;
}
system("PAUSE");
return 0;
}
Reply:Your input for the values is outside of your FOR loop. What is the "system("PAUSE");" for? See: http://www.gidnetwork.com/b-61.html
TMD
sweet pea
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment