Hello RCUniversal,
"dayNum" and "timeNum" are global variables ad defined where they should be except you never use them. The function "GetInput" will never change these variables, see previous message.
Passing a variable by reference is:
return type FunctionName(type& variable)
. The use of
& tells the function that the variable is a reference. If you have a proto type this needs to match the function definition. I am not sure of all the functions where you would need the variables for day and time, but the global variables you have defined will cover this need. What you need is some place in the program to give them a value to use.
Some system pauses in the program are needed. Which ones aren't? |
Any pause when backing out of a section is not needed. Any time you see "Press any key to continue . . . and another fallows, the second one is not needed. Like at the opening menu when you press 2 and say "Y" the program should end not wait for a key press. Places like that. I have not tracked down all unneeded places yet. Time and experience will help you here.
Consider this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
int GetInput()
{
int choice;
cin >> choice;
return choice;
int day;
cin >> day;
return day;
dayNum = day;
int time;
cin >> time;
return time;
timeNum = time;
}
|
The compiler will read the file in a top down method one line at a time. Keeping that in mind and starting at line 3, this will define the variable "choice" and reserve storage space for it. Always a good idea to initialize the variables when defined even if the next line will give it a value.
Lines 7, 8 and 9 are the same as above. line 10 will never be reached because of line 9 and first because of line 5.
Lines 12 - 15 same as above.
To use a function like this you would have to pass a variable to use to decide which part of the function to use with either a switch or if statements.
The "Weekday" and "Weekend" functions do not work well. You want an "int" for the time, but ask the user in a way that would expect a string. "time" will take everything up to the ":" leaving the rest and this is not what you want. Either take in a string and separate it into hours and minutes or enter for two variables, hours and minutes.
Hope that helps,
Andy