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
|
#include <iostream>
using namespace std;
struct monthlybudget //monthlybudget structure
{ double housing, utilities, householdExpns, trans, food, medical, insurance, entert, cloth, miscellaneous;
// constructor
monthlybudget(double house, double util,double houseEx,double tran, double foo, double medic, double insur,double ent, double clo, double misc)
{ housing = house;
utilities = util;
householdExpns = houseEx;
trans = tran;
food = foo;
medical = medic;
insurance = insur;
entert = ent;
cloth = clo;
miscellaneous = misc;
}
void displayData()
{ cout << housing;
cout << utilities;
cout << householdExpns;
cout << trans;
cout << food;
cout << medical;
cout << insurance;
cout << entert;
cout << cloth;
cout << miscellaneous;
cout << "\n";
}
};
//prototype
void getcurrent(monthlybudget&);
int main()
{ monthlybudget neededbud(500,150,65,50,250,30,100,150,75,50);
monthlybudget achievedbud;
cout << "Please enter your monthly expenses and I will compare them to your budget.\n" << endl;
neededbud.displayData();
achievedbud.displayData();
getcurrent(achievedbud);
system("pause");
return 0;
}
//Function to get input regarding the actual achieved budget
void getcurrent(monthlybudget &temp)
{ cout << "Enter amount for housing ";
cin >> temp.housing;
cout << "Enter amount for utilities ";
cin >> temp.utilities;
cout << "Enter amount for household expenses ";
cin >> temp.householdExpns;
cout << "Enter amount for transportation ";
cin >> temp.trans;
cout << "Enter amount for food ";
cin >> temp.food;
cout << "Enter amount for medical ";
cin >> temp.medical;
cout << "Enter amount for insurance ";
cin >> temp.insurance;
cout << "Enter amount for entertainment ";
cin >> temp.entert;
cout << "Enter amount for clothing ";
cin >> temp.cloth;
cout << "Enter amount for miscellaneous ";
cin >> temp.miscellaneous;
}
| |