First of all, since your
weather variable is an
int
, when it asks you for the weather, you have to enter an integer.
If that's not what you want,
#include <string>
and change
int weather;
to
string weather;
.
Now, your problem is that in
golf::calculate(), you declare three
int
variables (
sunny,
raining, and
overcast) that, since they are all uninitialized, all contain some random garbage values.
Then you try to compare your
weather variable with those values.
Unless the user is
really good at guessing what values to enter for it to be sunny, raining, or overcast, it's never going to be any of them.
So, if you change
weather to a
string like I suggested, you just have to do
1 2 3 4 5
|
if (weather == "sunny")
// etc.
else if (weather == "overcast")
// etc.
// and so on
|
and you don't need those other variables at the beginning.