ok i'm having quite a few problems with this structure program.
first i'm gonna explain what i have to do. i need to have a structure
1. store the name of stock, estimated earnings per share, estimated price-to-earnings ratio
2. have program prompt the user to enter these for 5 stocks using the same structure to store the data.
3. when data is entered have program compute and display stock price used by multiplying the entered earnings and price per share
here is what i have so far
CODE
#include <iostream>
#include <string>
using namespace std;
struct stocks
{
string stockNname;
float earningPerShare;
float priceToEarning;
};
void populate(stocks *);
void dispOne(stocks *);
int main()
{
char key;
stocks *recPoint
cout << "Do you want to enter the stock name? (y for yes n for no): ";
key = cin.get();
if (key == 'y')
{
key = cin.get();
recPoint= new stock;
populate(recPoint);
dispOne(recPoint);
else
cout <<"\nNo record has been created";
return 0;
}
void populate(stock *record)
{
cout << "Enter the stock name: ";
getline(cin, record->stockName);
cout << "Enter the Earnings Per Share";
getline(cin, record->earningPerShare);
cout << "Enter the Price To Earning Ratio";
getline(cin, record->priceToEarning;
return;
}
i know i need to add something like this for the 5 things to be entered
CODE
const int NUMRECS = 5;
int i, something here[NUMRECS ], total=0;
for (i=0; i < NUMRECS; i++)
{
cout << "enter something here\n";
cin >> something here[i];
}
how do i incorporate this?
This post has been edited by rollinhard: 20 Nov, 2005 - 04:23 PM