Hello Lacy9265,
Some things I have noticed so far:
In "main" "userAnswer" would be better as an "int" and for the menu you can do this:
1 2 3 4 5 6 7
|
std::cout <<
"1 -- Add a month of statistics\n"
"2 -- Edit a month of statistics\n"
"3 -- Print report\n"
"4 -- Quit\n"
" Enter Choice: ";
std::cin >> userAnswer;
|
You do not need a "cout" for every line. Each line in double quotes is considered 1 big string. This gives you the advantage of being easy to edit and it looks more like what your output will be.
For your if statement you have:
if (userAnswer = 'A')
. A single = means assign, so this is always true no mater what you enter for "userAnswer". You need (==) to compare.
You also need a way to check for either case:
if (userAnswer == 'A' || userAnswer == 'a')
or
if (std:toupper(userAnswer) == 'A')
, could also use tolower, or
userAnswer = std::toupper(userAnswer);
which would follow the "cin >> userAnswer;".
Another option is to replace the if statements with a "switch" where you could do:
1 2 3 4 5 6 7 8 9
|
switch (userAnswer)
{
case 'a':
case 'A':
// Code here
break;
default:
break;
}
|
Same concept for the other letters, but these letters should be replaced by numbers, no single quotes. Of course the choice is yours to make.
Line 42 has no use. This may produce an error or just a warning. Not sure which until I compile the code.
So far I have not figured out how you are storing the month. It looks like it may be an "int", but if you are going to use "Mar" it should be a string. I will know more when I get the code split up.
Andy