A few things for you to consider.
char symbol
(missing semi-colon? Lots of your code seems to be missing semi-colons at the end of statements)
symbol is a single
char. You then go on to attempt to test it for equality with, for example, AAPL. A single character will never be the same as four characters. You should get to grips with strings, both the C-style array of char with an associated char pointer, and the C++ std::string.
while{
while what? I think you've misunderstood what the while loop is for, and how it works.
You have an
if statement, and the only thin that happens if it is true is
cout<<"Main Menu\n":
That colon is presumably meant to be a semi-colon. If you want the if statement to trigger more than one statement if it is true, you must use braces, like this:
1 2 3 4 5 6
|
if (something that might be true)
{
//do this
// and this
// and this as well
}
|
Best read up on how the
if statement works.
if (0<choice<8)
That's just a nonsense. I think you meant
if ((0 < choice) && (choice < 8))
which is if choice is greater than zero, and choice is less than 8.
Your switchyard contains no
break;
statements. If the choice made is case 1, when the case 1 code is finished, it will go on to do the case 2 code, and the case three code, and on and on until it reaches a break statement or gets to the end.
I advise you to look up how
switch
and
case
work, and read some examples.
You've defined a Stock class, but never use it. If you're not going to use it, why have it? I think you've misunderstood how classes work, as you then go on to define the getChangePercent as a function at the end.
All this lot:
1 2 3 4 5 6 7 8 9
|
//sell option after figureing out share balance
{
Cout<<"Please enter in whole numbers the amount of dollars of stock you wish to sell.\n";
cin>> share
if(share<500 || share<balance)
cout<<"Sale invalid.\n";
else cout<<"Congratulations, you have just sold $"<<share<<" worth of stock.\n";
balance=balance-share
}
|
will never be used and is just hanging around at the end.
I think you've started at too high a level for your experience and knowledge. You might find it easier to start with something simpler and work up, or break this chosen exercise into sub-components and solving each in turn (the divide-and-conquer method of coding, which is often very effective).