Hello ashley50,
Thank you the link to GitHub it worked. Now many parts of the program make more sense.
Just some FYI for your consideration.
As an example.
1 2 3
|
for (i = 0 ; i < size ; i++) {
sum += gross[i];
}
|
Although there is nothing wrong with writing the {}s like this, it works. But when you write a block of code that could span more than one screen it makes it hard to see where the opening and closing {}s are.
I prefer this because it makes it easier to find the opening and closing {}s.
1 2 3 4
|
for (i = 0 ; i < size ; i++)
{
sum += gross[i];
}
|
Not only is it easier to see the opening and closing{}s. If the closing brace is in the next screen with the opening and closing {}s being in the same column it is easier to match up. Also should you have 3 or 4 lines of closing {}s it is easier to find when you are missing a closing }.
Not real important just something to think about.
The "get_yesno" function could be done in an easier way and still have th ame result along with shorting the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
char get_yesno(std::string question)
{
char answer; // player's yes/no response
do {
std::cout << std::endl;
std::cout << question << " (Y/N)? ";
std::cin >> answer;
answer = toupper(answer);
// Convert lower-case responses to upper case
//if (answer == 'y') {
// answer = 'Y';
//}
//else if (answer == 'n') {
// answer = 'N';
//}
if (answer != 'Y' && answer != 'N') {
std::cout << "Please enter 'Y' for yes or 'N' for no"
<< std::endl;
}
} while (answer != 'Y' && answer != 'N');
return answer;
}
|
It is possible that you could pass "answer" by reference and not need the return value.
If you are familiar with structs I refer you to my earlier post about the struct. If not I will help you all I can to understand.
The in main you would only have to define one array like:
Info aEmp[MAXSIZE];
. The "a" gives you a hint that the variable is an array. Not really necessary if you do not want to use it. I used "MAXSIZE" over the "SIZE" as I see in your previous post. Either one will work, but "MAXSIZE" is more often seen used here. in the end it is your choice.
As I started to work with what you have in your OP I found the struct and array of structs to be the easiest to use. This way you only have to pass one array to functions along with the count of how many elements that you used.
To work without using the struct you would have to create several arrays to hold all the information that you will need. And then passing all those arrays to functions would be tedious.
While I am thinking about it the "join_name" function is not really needed. This can just as easily be done right after you enter the "first" and "last" names with out the need to call a function. Since it is there you can still use it.
Now that I can see the whole program I will need a little time to go through it and see what needs to be changed.
Hope that helps,
Andy