Trying to get the calcuation for the expenditures to work.

I want to make a program for a students monthly budget but I can get the calculation to work. I know actual.gross += actual; is wrong but I am not sure what to do besides that.

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
  #include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

const int NUM_EXP = 10;
const int EXP_AMT = 1500.;

struct MonthlyBudget { 
int housing; 
int utilities; 
int householdExpenses; 
int transporation; 
int food;
int medical;
int insurance;
int entertainment;
int clothing;
int miscellaneous;
int gross;
};

int main()
  {
MonthlyBudget actual;
cout << "Enter amount for housing ";
  cin >> actual.housing;
  cout << "Enter amount for utilities ";
  cin >> actual.utilities;
  cout << "Enter amount for household expenses ";
  cin >> actual.householdExpenses;
  cout << "Enter amount for transportation ";
  cin >> actual.transporation;
  cout << "Enter amount for food ";
  cin >> actual.food;
  cout << "Enter amount for medical ";
  cin >> actual.medical;
  cout << "Enter amount for insurance ";
  cin >> actual.insurance;
  cout << "Enter amount for entertainment ";
  cin >> actual.entertainment;
  cout << "Enter amount for clothing ";
  cin >> actual.clothing;
  cout << "Enter amount for miscellaneous ";
  cin >> actual.miscellaneous;

//Calculate the student's expenditures for the month
actual.gross += actual;

if actual.gross < EXP_AMT;
{
under= actutal.gross - EXP_AMT
cout << "You have are below your budget by $ " << under << endl;
}

if EXP_AMT = actual.gross; 
{
cout << "You are right at your monthly budget";
}

if EXP_AMT > actual.gross; 
{
over= EXP_AMT - actual.gross
cout << "You are over your monthly budget by: $ " << over <<endl;

}
system ("pause")
return 0;
}

I know actual.gross += actual; is wrong but I am not sure what to do besides that.

You'll need to add each of the different categories to the gross if you want gross cost.

Ok thank you. I add the different categories but now i am having issues with line 51 i get this error Error 2 error C2061: syntax error : identifier 'actual'. This is throwing me off since actual work until this point. should i do gross instead of actual.gross?
Line 8: Don't initialize a const int to a float value.

Line 49: You can't add a struct to gross.

Line 51, 57, 62: Your if statements are bogus. The condition must be enclosed in (). The ; terminates the if statement. Remove it.

Line 57: You're using the assignment operator(=), not the comparison operator (==).

Line 53,64,68: You're missing a ;

Line 53: under is not defined.

Line 64: over is not defined.


Thank you, I did not realize all those mistakes. Thank you so much
Topic archived. No new replies allowed.