Problem

Pages: 12
Ok, i was doing well but my program is big and i got confused, im not sure what is wrong.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int treasury(long int &M);
void game(string &PN, string CN, long int &M);
void save(string &PN, string CN, long int &M);
void NatManager(long int &M);
void MnthDeduct(long int &M, long int &HC, double &TXR);

int main()
{
    int choice;
    long int money = 1000000000;
    string Pname;
    string Cname;

    cout << "1) New" << endl;
    cout << "2) Load" << endl;
    cin >> choice;

    switch(choice)
    {
        case 1:
            {

                cin.sync();
                cout << "Welcome please enter your name" << endl;
                getline(cin, Pname);
                cout << "\n";
                cin.sync();
                cout << "Thank you " << Pname << " now please enter your countries name." << endl;
                getline(cin, Cname);

                cout << "Welcome " << Pname << " to " << Cname << endl;
                cout << "Press ENTER to continue\n" << endl;
                cin.get();

                save(Pname, Cname, money);
            }
            break;
        case 2:
            {
                ifstream file("President.txt");

                getline(file, Pname);
                getline(file, Cname);
                file >> money;

                game(Pname, Cname, money);
            }
            break;
        default:
            cout << "Error" << endl;
    }
}

void game(string &PN, string CN, long int &M, long int &HC, double &TXR)
{
    int choice;

    cout << "What will you do?\n" << endl;

    cout << "1) Go to Treasury" << endl;
    cout << "2) Go to Nation Manager" << endl;
    cout << "3) View monthly deductable" << endl;
    cin >> choice;

        switch(choice)
        {
            case 1:
                treasury(M);
                break;
            case 2:
                NatManager(M);
                break;
            case 3:
                MnthDeduct(M,HC,TXR);
        }
}

int treasury(long int &M)
{
    cout << "NATIONAL TREASURY\n" << endl;

    cout << "Current money in treasury: " << M << endl;
}

void save(string &PN, string CN, long int &M)
{
    ofstream file;
    file.open("President.txt");

    file << PN << endl;
    file << CN << endl;
    file << M << endl;

    file.close();

    //return game(PN,CN,M);
}

void NatManager(long int &M)
{
    int choice;
    long int healC = 0;
    double taxR = 0;
    long int hCare = 0;
    double taxRate = 0;

    cout << "What do you want to do here?\n" << endl;

    cout << "1) Modify Healthcare" << endl;
    cout << "2) Modify Taxes" << endl;
    cout << "3) Pass/veto bills" << endl;
    cin >> choice;
    cout << "\n";

        switch(choice)
        {
            case 1:
                cout << "MODIFY HEALTHCARE\n" << endl;

                cout << "Current Healthcare budget: $" << hCare << endl;
                cout << "What would you like to change the budget to?" << endl;
                cout << "Current Government Budget: $" << M << endl;
                cin >> healC;

                if(healC < M)
                {
                    hCare = healC;

                    cout << "\n";
                    cout << "Ok current Healthcare budget is set to: $" << hCare << endl;
                    cout << "Current National budget: $" << M - healC << endl;
                }
                else if(healC > M)
                {
                    cout << "Thats more money than you have!" << endl;
                }
                break;
            case 2:
                cout << "MODIFY TAXES\n" << endl;

                cout << "Current Tax Rate: %" << taxRate << endl;
                cout << "What would you like to change the Tax Rate to?" << endl;
                cin >> taxR;

                cout << "\n";

                taxRate = taxR;

                cout << "Ok the current tax rate is now: %" << taxRate << endl;

        }
}

void MnthDeduct(long int &M, long int &hCare, double &taxRate)
{
    cout << "MONTHLY DEDUCTIBLE\n" << endl;


}


C:\Users\Chay Hawk\Desktop\President\main.cpp||In function 'int treasury(long int&)':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|89|warning: no return statement in function returning non-void|
obj\Debug\main.o||In function `main':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|52|undefined reference to `game(std::string&, std::string, long&)'|
||=== Build finished: 1 errors, 1 warnings ===|
Last edited on
The compiler messages are very clear. Read them and see the statements which pointed in the error messages. Compare called functions with their declarations.
Look at how you defined game function. The warning message is obvious too. You should learn how to understand compiler warnings and errors.
ok i seriousley dont know what the fuck.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int treasury(long int &M);
void game(long int &M, long int &HC, double &TXR);
void save(string &PN, string CN, long int &M);
void NatManager(long int &M);
void MnthDeduct(long int &M, long int &HC, double &TXR);

int main()
{
    int choice;
    long int money = 1000000000;
    string Pname;
    string Cname;

    cout << "1) New" << endl;
    cout << "2) Load" << endl;
    cin >> choice;

    switch(choice)
    {
        case 1:
            {

                cin.sync();
                cout << "Welcome please enter your name" << endl;
                getline(cin, Pname);
                cout << "\n";
                cin.sync();
                cout << "Thank you " << Pname << " now please enter your countries name." << endl;
                getline(cin, Cname);

                cout << "Welcome " << Pname << " to " << Cname << endl;
                cout << "Press ENTER to continue\n" << endl;
                cin.get();

                save(Pname, Cname, money);
            }
            break;
        case 2:
            {
                ifstream file("President.txt");

                getline(file, Pname);
                getline(file, Cname);
                file >> money;

                game(money);
            }
            break;
        default:
            cout << "Error" << endl;
    }
}

void game(long int &M, long int &HC, double &TXR)
{
    int choice;

    cout << "What will you do?\n" << endl;

    cout << "1) Go to Treasury" << endl;
    cout << "2) Go to Nation Manager" << endl;
    cout << "3) View monthly deductable" << endl;
    cin >> choice;

        switch(choice)
        {
            case 1:
                treasury(M);
                break;
            case 2:
                NatManager(M);
                break;
            case 3:
                MnthDeduct(M,HC,TXR);
        }
}

int treasury(long int &M)
{
    cout << "NATIONAL TREASURY\n" << endl;

    cout << "Current money in treasury: " << M << endl;
}

void save(string &PN, string CN, long int &M)
{
    ofstream file;
    file.open("President.txt");

    file << PN << endl;
    file << CN << endl;
    file << M << endl;

    file.close();

    return game(M);
}

void NatManager(long int &M)
{
    int choice;
    long int healC = 0;
    double taxR = 0;
    long int hCare = 0;
    double taxRate = 0;

    cout << "What do you want to do here?\n" << endl;

    cout << "1) Modify Healthcare" << endl;
    cout << "2) Modify Taxes" << endl;
    cout << "3) Pass/veto bills" << endl;
    cin >> choice;
    cout << "\n";

        switch(choice)
        {
            case 1:
                cout << "MODIFY HEALTHCARE\n" << endl;

                cout << "Current Healthcare budget: $" << hCare << endl;
                cout << "What would you like to change the budget to?" << endl;
                cout << "Current Government Budget: $" << M << endl;
                cin >> healC;

                if(healC < M)
                {
                    hCare = healC;

                    cout << "\n";
                    cout << "Ok current Healthcare budget is set to: $" << hCare << endl;
                    cout << "Current National budget: $" << M - healC << endl;
                }
                else if(healC > M)
                {
                    cout << "Thats more money than you have!" << endl;
                }
                break;
            case 2:
                cout << "MODIFY TAXES\n" << endl;

                cout << "Current Tax Rate: %" << taxRate << endl;
                cout << "What would you like to change the Tax Rate to?" << endl;
                cin >> taxR;

                cout << "\n";

                taxRate = taxR;

                cout << "Ok the current tax rate is now: %" << taxRate << endl;
        }
}

void MnthDeduct(long int &M, long int &HC, double &TXR)
{
    cout << "MONTHLY DEDUCTIBLE\n" << endl;

    cout << M << "" << HC << "" << TXR << endl;
}



C:\Users\Chay Hawk\Desktop\President\main.cpp||In function 'int main()':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|8|error: too few arguments to function 'void game(long int&, long int&, double&)'|
C:\Users\Chay Hawk\Desktop\President\main.cpp|52|error: at this point in file|
C:\Users\Chay Hawk\Desktop\President\main.cpp||In function 'int treasury(long int&)':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|89|warning: no return statement in function returning non-void|
C:\Users\Chay Hawk\Desktop\President\main.cpp||In function 'void save(std::string&, std::string, long int&)':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|60|error: too few arguments to function 'void game(long int&, long int&, double&)'|
C:\Users\Chay Hawk\Desktop\President\main.cpp|102|error: at this point in file|
C:\Users\Chay Hawk\Desktop\President\main.cpp|102|error: return-statement with a value, in function returning 'void'|
||=== Build finished: 5 errors, 1 warnings ===|


every time i try to fix it it just gives me more and more errors.
Do i need to make game function an int? or something?
Last edited on
The function declaration argument list have to match its definition argument list.
Last edited on
Thats just a bunch of jibberish to me. Im not trying to be rude, i just am not good with technical lingo.
That's very basic actually. If you don't understand that information, I suggest you read a book or take a look at the documentation.

You are declaring treasury to return an int, but the function doesn't return anything, hence the warning you are getting.

The function argument list here : void game(string &PN, string CN, long int &M); doesn't match what you have here :
1
2
3
4
void game(string &PN, string CN, long int &M, long int &HC, double &TXR) 
{
    // code goes here
}


That's why you are getting the error.

Ok now i get this error and i tried 2 different ways but cant figure it out

why does it keep giving me this?


C:\Users\Chay Hawk\Desktop\President\main.cpp||In function 'int main()':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|52|error: 'hCare' was not declared in this scope|
C:\Users\Chay Hawk\Desktop\President\main.cpp|52|error: 'taxRate' was not declared in this scope|
||=== Build finished: 2 errors, 0 warnings ===|


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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

void treasury(long int &M);
void game(long int &M, long int &HC, double &TXR);
void save(string &PN, string CN, long int &M);
void NatManager(long int &M);
void MnthDeduct(long int &M, long int &HC, double &TXR);

int main()
{
    int choice;
    long int money = 1000000000;
    string Pname;
    string Cname;

    cout << "1) New" << endl;
    cout << "2) Load" << endl;
    cin >> choice;

    switch(choice)
    {
        case 1:
            {

                cin.sync();
                cout << "Welcome please enter your name" << endl;
                getline(cin, Pname);
                cout << "\n";
                cin.sync();
                cout << "Thank you " << Pname << " now please enter your countries name." << endl;
                getline(cin, Cname);

                cout << "Welcome " << Pname << " to " << Cname << endl;
                cout << "Press ENTER to continue\n" << endl;
                cin.get();

                save(Pname, Cname, money);
            }
            break;
        case 2:
            {
                ifstream file("President.txt");

                getline(file, Pname);
                getline(file, Cname);
                file >> money;

                game(money, hCare, taxRate);
            }
            break;
        default:
            cout << "Error" << endl;
    }
}

void game(long int &M, long int &HC, double &TXR)
{
    int choice;

    cout << "What will you do?\n" << endl;

    cout << "1) Go to Treasury" << endl;
    cout << "2) Go to Nation Manager" << endl;
    cout << "3) View monthly deductable" << endl;
    cin >> choice;

        switch(choice)
        {
            case 1:
                treasury(M);
                break;
            case 2:
                NatManager(M);
                break;
        }
}

void treasury(long int &M)
{
    cout << "NATIONAL TREASURY\n" << endl;

    cout << "Current money in treasury: " << M << endl;
}

void save(string &PN, string CN, long int &M, long int &HC, double &TXR)
{
    ofstream file;
    file.open("President.txt");

    file << PN << endl;
    file << CN << endl;
    file << M << endl;

    file.close();

    //return game(M,HC,TXR);
}

void NatManager(long int &M)
{
    int choice;
    long int healC = 0;
    double taxR = 0;
    long int hCare = 0;
    double taxRate = 0;

    cout << "What do you want to do here?\n" << endl;

    cout << "1) Modify Healthcare" << endl;
    cout << "2) Modify Taxes" << endl;
    cout << "3) Pass/veto bills" << endl;
    cin >> choice;
    cout << "\n";

        switch(choice)
        {
            case 1:
                cout << "MODIFY HEALTHCARE\n" << endl;

                cout << "Current Healthcare budget: $" << hCare << endl;
                cout << "What would you like to change the budget to?" << endl;
                cout << "Current Government Budget: $" << M << endl;
                cin >> healC;

                if(healC < M)
                {
                    hCare = healC;

                    cout << "\n";
                    cout << "Ok current Healthcare budget is set to: $" << hCare << endl;
                    cout << "Current National budget: $" << M - healC << endl;
                }
                else if(healC > M)
                {
                    cout << "Thats more money than you have!" << endl;
                }
                break;
            case 2:
                cout << "MODIFY TAXES\n" << endl;

                cout << "Current Tax Rate: %" << taxRate << endl;
                cout << "What would you like to change the Tax Rate to?" << endl;
                cin >> taxR;

                cout << "\n";

                taxRate = taxR;

                cout << "Ok the current tax rate is now: %" << taxRate << endl;
        }
}

void MnthDeduct(long int &M, long int &HC, double &TXR)
{
    cout << "MONTHLY DEDUCTIBLE\n" << endl;

    cout << M << "" << HC << "" << TXR << endl;
}
Last edited on
The errors are VERY clear. You are passing hCare and taxRate to function game() but they are not declared in the scope of main().
But i thought they didnt need to be in main for me to be able to pass them? if they have to be in main then i know what to do to fix it.
They don't need to be declared in main, but they need to be accessed in main().
Oh ok so how would i do that? hCare = HC, taxRate = TXR?
Last edited on
You can't access those variables in main() function. You can declare them at global scope(which is discouraged), or declare them in main() and then pass them to other functions that needs them, or you could make a new function to do most of the work main() does and pass those variables to it. There are many other solutions, you just have to think of one.
Last edited on
Ok so when you say pass those variables to main, do you mean put arguments in the parameters? i though that was illegal?
Ok i got it working, but goddam soooo many references its confusing as hell. How do people work like this? this is what classes are for arent they. I had a feeling deep down that those variables needed to be in main but i didnt trust myself.

Heres the new code, does it look ok so far?

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

void treasury(long int &M);
void game(long int &M, long int &HC, double &TXR);
void save(string &PN, string CN, long int &M);
void NatManager(long int &M, long int &HC, double &TXR);
void MnthDeduct(long int &M, long int &HC, double &TXR);

int main()
{
    int choice;
    long int money = 1000000000;
    string Pname;
    string Cname;
    long int hCare = 0;
    double taxRate = 0;

    cout << "1) New" << endl;
    cout << "2) Load" << endl;
    cin >> choice;

    switch(choice)
    {
        case 1:
            {

                cin.sync();
                cout << "Welcome please enter your name" << endl;
                getline(cin, Pname);
                cout << "\n";
                cin.sync();
                cout << "Thank you " << Pname << " now please enter your countries name." << endl;
                getline(cin, Cname);

                cout << "Welcome " << Pname << " to " << Cname << endl;
                cout << "Press ENTER to continue\n" << endl;
                cin.get();

                save(Pname, Cname, money);
            }
            break;
        case 2:
            {
                ifstream file("President.txt");

                getline(file, Pname);
                getline(file, Cname);
                file >> money;

                game(money, hCare, taxRate);
            }
            break;
        default:
            cout << "Error" << endl;
    }
}

void game(long int &M, long int &HC, double &TXR)
{
    int choice;

    cout << "What will you do?\n" << endl;

    cout << "1) Go to Treasury" << endl;
    cout << "2) Go to Nation Manager" << endl;
    cout << "3) View monthly deductable" << endl;
    cin >> choice;

        switch(choice)
        {
            case 1:
                treasury(M);
                break;
            case 2:
                NatManager(M, HC, TXR);
                break;
            case 3:
                MnthDeduct(M, HC, TXR);
        }
}

void treasury(long int &M)
{
    cout << "NATIONAL TREASURY\n" << endl;

    cout << "Current money in treasury: " << M << endl;
}

void save(string &PN, string CN, long int &M)
{
    ofstream file;
    file.open("President.txt");

    file << PN << endl;
    file << CN << endl;
    file << M << endl;

    file.close();

    //return game(M,HC,TXR);
}

void NatManager(long int &M, long int &HC, double &TXR)
{
    int choice;
    long int healC = 0;
    double taxR = 0;

    cout << "What do you want to do here?\n" << endl;

    cout << "1) Modify Healthcare" << endl;
    cout << "2) Modify Taxes" << endl;
    cout << "3) Pass/veto bills" << endl;
    cin >> choice;
    cout << "\n";

        switch(choice)
        {
            case 1:
                cout << "MODIFY HEALTHCARE\n" << endl;

                cout << "Current Healthcare budget: $" << HC << endl;
                cout << "What would you like to change the budget to?" << endl;
                cout << "Current Government Budget: $" << M << endl;
                cin >> healC;

                if(healC < M)
                {
                    HC = healC;

                    cout << "\n";
                    cout << "Ok current Healthcare budget is set to: $" << HC << endl;
                    cout << "Current National budget: $" << M - healC << endl;
                }
                else if(healC > M)
                {
                    cout << "Thats more money than you have!" << endl;
                }
                break;
            case 2:
                cout << "MODIFY TAXES\n" << endl;

                cout << "Current Tax Rate: %" << TXR << endl;
                cout << "What would you like to change the Tax Rate to?" << endl;
                cin >> taxR;

                cout << "\n";

                TXR = taxR;

                cout << "Ok the current tax rate is now: %" << TXR << endl;
        }
}

void MnthDeduct(long int &M, long int &HC, double &TXR)
{
    cout << "MONTHLY DEDUCTIBLE\n" << endl;

    cout << M << "" << HC << "" << TXR << endl;
}


void Variables()
{
    long int money = 1000000000;
    string Pname;
    string Cname;
    long int hCare = 0;
    double taxRate = 0;
}
Last edited on
What does this mean? I got like 8 errors and i was able to fix them all but this one.

C:\Users\Chay Hawk\Desktop\President\main.cpp||In function 'void Variables()':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|178|warning: unused variable 'money'|
C:\Users\Chay Hawk\Desktop\President\main.cpp|181|warning: unused variable 'hCare'|
C:\Users\Chay Hawk\Desktop\President\main.cpp|182|warning: unused variable 'taxRate'|
obj\Debug\main.o||In function `main':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|43|undefined reference to `save(std::string&, std::string&, long&, long&, double&)'|
obj\Debug\main.o||In function `Z4gameRSsS_RlS0_Rd':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|88|undefined reference to `save(std::string&, std::string&, long&, long&, double&)'|
||=== Build finished: 2 errors, 3 warnings ===|


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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

void treasury(long int &M);
void game(string &PN, string &CN, long int &M, long int &HC, double &TXR);
int save(string &PN, string &CN, long int &M, long int &HC, double &TXR);
void NatManager(long int &M, long int &HC, double &TXR);
void MnthDeduct(long int &M, long int &HC, double &TXR);

int main()
{
    int choice;
    long int money = 1000000000;
    string Pname;
    string Cname;
    long int hCare = 0;
    double taxRate = 0;

    cout << "1) New" << endl;
    cout << "2) Load" << endl;
    cin >> choice;

    switch(choice)
    {
        case 1:
            {

                cin.sync();
                cout << "Welcome please enter your name" << endl;
                getline(cin, Pname);
                cout << "\n";
                cin.sync();
                cout << "Thank you " << Pname << " now please enter your countries name." << endl;
                getline(cin, Cname);

                cout << "Welcome " << Pname << " to " << Cname << endl;
                cout << "Press ENTER to continue\n" << endl;
                cin.get();

                save(Pname, Cname, money, hCare, taxRate);
            }
            break;
        case 2:
            {
                ifstream file("President.txt");

                getline(file, Pname);
                getline(file, Cname);
                file >> money;
                file >> hCare;
                file >> taxRate;

                game(Pname,Cname,money,hCare,taxRate);
            }
            break;
        default:
            cout << "Error" << endl;
    }
}

void game(string &PN, string &CN, long int &M, long int &HC, double &TXR)
{
    int choice;

    cout << "What will you do?\n" << endl;

    cout << "1) Go to Treasury" << endl;
    cout << "2) Go to Nation Manager" << endl;
    cout << "3) View monthly deductions" << endl;
    cout << "4) Save" << endl;
    cin >> choice;

        switch(choice)
        {
            case 1:
                treasury(M);
                break;
            case 2:
                NatManager(M, HC, TXR);
                break;
            case 3:
                MnthDeduct(M, HC, TXR);
                break;
            case 4:
                save(PN,CN,M,HC,TXR);
                break;
        }
}

void treasury(long int &M)
{
    cout << "NATIONAL TREASURY\n" << endl;

    cout << "Current money in treasury: " << M << endl;
}

int save(string &PN, string CN, long int &M, long int &HC, double &TXR)
{
    ofstream file;
    file.open("President.txt");

    file << PN << endl;
    file << CN << endl;
    file << M << endl;
    file << HC << endl;
    file << TXR << endl;

    file.close();

    return game(PN,CN,M,HC,TXR);
}

void NatManager(long int &M, long int &HC, double &TXR)
{
    int choice;
    long int healC = 0;
    double taxR = 0;

    cout << "What do you want to do here?\n" << endl;

    cout << "1) Modify Healthcare" << endl;
    cout << "2) Modify Taxes" << endl;
    cout << "3) Pass/veto bills" << endl;
    cin >> choice;
    cout << "\n";

        switch(choice)
        {
            case 1:
                cout << "MODIFY HEALTHCARE\n" << endl;

                cout << "Current Healthcare budget: $" << HC << endl;
                cout << "What would you like to change the budget to?" << endl;
                cout << "Current Government Budget: $" << M << endl;
                cin >> healC;

                if(healC < M)
                {
                    HC = healC;

                    cout << "\n";
                    cout << "Ok current Healthcare budget is set to: $" << HC << endl;
                    cout << "Current National budget: $" << M - healC << endl;
                }
                else if(healC > M)
                {
                    cout << "Thats more money than you have!" << endl;
                }
                break;
            case 2:
                cout << "MODIFY TAXES\n" << endl;

                cout << "Current Tax Rate: %" << TXR << endl;
                cout << "What would you like to change the Tax Rate to?" << endl;
                cin >> taxR;

                cout << "\n";

                TXR = taxR;

                cout << "Ok the current tax rate is now: %" << TXR << endl;
        }
}

void MnthDeduct(long int &M, long int &HC, double &TXR)
{
    cout << "MONTHLY DEDUCTIBLE\n" << endl;

    cout << M << "" << HC << "" << TXR << endl;
}


void Variables()
{
    long int money = 1000000000;
    string Pname;
    string Cname;
    long int hCare = 0;
    double taxRate = 0;
}
Last edited on
You missed a reference operator in save definition.
Where? what line?
Oh i see it, yeah i fixed that and still get errors:

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

void treasury(long int &M);
void game(string &PN, string &CN, long int &M, long int &HC, double &TXR);
int save(string &PN, string &CN, long int &M, long int &HC, double &TXR);
void NatManager(long int &M, long int &HC, double &TXR);
void MnthDeduct(long int &M, long int &HC, double &TXR);

int main()
{
    int choice;
    long int money = 1000000000;
    string Pname;
    string Cname;
    long int hCare = 0;
    double taxRate = 0;

    cout << "1) New" << endl;
    cout << "2) Load" << endl;
    cin >> choice;

    switch(choice)
    {
        case 1:
            {

                cin.sync();
                cout << "Welcome please enter your name" << endl;
                getline(cin, Pname);
                cout << "\n";
                cin.sync();
                cout << "Thank you " << Pname << " now please enter your countries name." << endl;
                getline(cin, Cname);

                cout << "Welcome " << Pname << " to " << Cname << endl;
                cout << "Press ENTER to continue\n" << endl;
                cin.get();

                save(Pname, Cname, money, hCare, taxRate);
            }
            break;
        case 2:
            {
                ifstream file("President.txt");

                getline(file, Pname);
                getline(file, Cname);
                file >> money;
                file >> hCare;
                file >> taxRate;

                game(Pname,Cname,money,hCare,taxRate);
            }
            break;
        default:
            cout << "Error" << endl;
    }
}

void game(string &PN, string &CN, long int &M, long int &HC, double &TXR)
{
    int choice;

    cout << "What will you do?\n" << endl;

    cout << "1) Go to Treasury" << endl;
    cout << "2) Go to Nation Manager" << endl;
    cout << "3) View monthly deductions" << endl;
    cout << "4) Save" << endl;
    cin >> choice;

        switch(choice)
        {
            case 1:
                treasury(M);
                break;
            case 2:
                NatManager(M, HC, TXR);
                break;
            case 3:
                MnthDeduct(M, HC, TXR);
                break;
            case 4:
                save(PN,CN,M,HC,TXR);
                break;
        }
}

void treasury(long int &M)
{
    cout << "NATIONAL TREASURY\n" << endl;

    cout << "Current money in treasury: " << M << endl;
}

int save(string &PN, string &CN, long int &M, long int &HC, double &TXR)
{
    ofstream file;
    file.open("President.txt");

    file << PN << endl;
    file << CN << endl;
    file << M << endl;
    file << HC << endl;
    file << TXR << endl;

    file.close();

    return game(PN,CN,M,HC,TXR);
}

void NatManager(long int &M, long int &HC, double &TXR)
{
    int choice;
    long int healC = 0;
    double taxR = 0;

    cout << "What do you want to do here?\n" << endl;

    cout << "1) Modify Healthcare" << endl;
    cout << "2) Modify Taxes" << endl;
    cout << "3) Pass/veto bills" << endl;
    cin >> choice;
    cout << "\n";

        switch(choice)
        {
            case 1:
                cout << "MODIFY HEALTHCARE\n" << endl;

                cout << "Current Healthcare budget: $" << HC << endl;
                cout << "What would you like to change the budget to?" << endl;
                cout << "Current Government Budget: $" << M << endl;
                cin >> healC;

                if(healC < M)
                {
                    HC = healC;

                    cout << "\n";
                    cout << "Ok current Healthcare budget is set to: $" << HC << endl;
                    cout << "Current National budget: $" << M - healC << endl;
                }
                else if(healC > M)
                {
                    cout << "Thats more money than you have!" << endl;
                }
                break;
            case 2:
                cout << "MODIFY TAXES\n" << endl;

                cout << "Current Tax Rate: %" << TXR << endl;
                cout << "What would you like to change the Tax Rate to?" << endl;
                cin >> taxR;

                cout << "\n";

                TXR = taxR;

                cout << "Ok the current tax rate is now: %" << TXR << endl;
        }
}

void MnthDeduct(long int &M, long int &HC, double &TXR)
{
    cout << "MONTHLY DEDUCTIBLE\n" << endl;

    cout << M << "" << HC << "" << TXR << endl;
}


void Variables()
{
    long int money = 1000000000;
    string Pname;
    string Cname;
    long int hCare = 0;
    double taxRate = 0;
}



C:\Users\Chay Hawk\Desktop\President\main.cpp||In function 'int save(std::string&, std::string&, long int&, long int&, double&)':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|113|error: void value not ignored as it ought to be|
C:\Users\Chay Hawk\Desktop\President\main.cpp||In function 'void Variables()':|
C:\Users\Chay Hawk\Desktop\President\main.cpp|178|warning: unused variable 'money'|
C:\Users\Chay Hawk\Desktop\President\main.cpp|181|warning: unused variable 'hCare'|
C:\Users\Chay Hawk\Desktop\President\main.cpp|182|warning: unused variable 'taxRate'|
||=== Build finished: 1 errors, 3 warnings ===|
Last edited on
Pages: 12