You own shares of 4 different companies. You need to write a program to store the following information of the stocks and then to display it. The information to be stored for each company are:
Company Name
Number of shares
Unit price of the shares
Total Value of the shares of company
The' Total Value of the shares of company' should be calculated as result of Number of shares * Unit price of the shares. All these information except the The' Total Value of the shares of company' should be obtained from the user and should be stored in an array. Once the array has been populated (for all companies), print the complete information about each company and total value of stocks. Here is an example of the output.
Company Number of Shares Unit Price Total Value of the shares of company
Company A 100 10 1000
Company B 200 10.5 2100
Company C 81 20 1620
Company D 23.5 10 235
Total Value of Stocks : 4955
create an array of struct.
.
this is what l created but it is not building, from 25 errors l got 8 errors now, above is the question
struct mystruct;
#include <iostream>
#include <conio.h>
using namespace std;
//structure declaration;
struct shares
thanks all but l am still having problem building it, right now l have 8 errors from 25 errors showing.
really appreciate you guys. l would not mind if you can still help me succeed in this, this is my first shot in programming and l want to be successful
#include <iostream>
#include <conio.h>
usingnamespace std;
//structure declaration;
struct shares
{
string CompanyName;
int Number_of_shares;
double Unit_price_of_shares;
};
//function prototype;
void enterCompanyName (shares shares[]);
void printshares (shares shars[]);
constint sizeOfArray = 50;
int main()
{
shares shares[sizeOfArray];
int amount; //**You will need to ask the user how many they want to enter.
int count;
//input the shares
for (int i = 0; i < amount; i++)
{
cin >> shares[i].Number_of_shares; // number of shares or unit price
}
//Display totalshares
cout << "The shares entered are: \n"
<< printshares;
_getch();
return 0;
}
//Functions
//Prints out the array of company
void printshares(shares shares[])
{
for(int i = 0; i < i; i++)
{
cout << shares[i].Unit_price_of_shares;
}
cout << endl;
}
//Functions
//Prints out the array of company
void printshares(shares shares[])
{
for(int i = 0; i < i; i++)
{
cout << shares[i].Unit_price_of_shares;
}
cout << endl;
l need to debug to input some figures but the black screen pops out and when l enter any no it goes away.. it does compile successful but has 1 warning