Monday, July 20, 2009

Monthly Expenses program using structure

Monthly Expenses program using structure (Source Code)

The c++ program in the previous post is improved here. I used structure to group the Income and Expenses data. I hope you can understand the program easily.


#include <>
#include <>
void main()
{
struct income {
float nSalary, nRentRec, nOtherIn;
};
struct expenses {
float nRentPaid, nPUB, nTele, nEdKid, nEdSelf, nMed, nInsur;
};
struct income MyIncome;
struct expenses MyExpenses;
float nInTotal, nExTotal, nBalance;
clrscr();
cout<<"Monthly Expenses Vs Income\n"; cout<<"--------------------------\n"; cout<<"INCOME\n"; cout<<"======\n"; cout<<"Salary :";cin>>MyIncome.nSalary;
cout<<"Rent Received :";cin>>MyIncome.nRentRec;
cout<<"Other Income :";cin>>MyIncome.nOtherIn;
cout<<"EXPENSES\n"; cout<<"========\n"; cout<<"Rent Paid :";cin>>MyExpenses.nRentPaid;
cout<<"Public Utility :";cin>>MyExpenses.nPUB;
cout<<"Telephone :";cin>>MyExpenses.nTele;
cout<<"Education-Kids :";cin>>MyExpenses.nEdKid;
cout<<"Education-Self :";cin>>MyExpenses.nEdSelf;
cout<<"Medical :";cin>>MyExpenses.nMed;
cout<<"Insurance :";cin>>MyExpenses.nInsur;
nInTotal = MyIncome.nSalary + MyIncome.nRentRec + MyIncome.nOtherIn;
nExTotal = MyExpenses.nRentPaid + MyExpenses.nPUB
+ MyExpenses.nTele + MyExpenses.nEdKid
+ MyExpenses.nEdSelf + MyExpenses.nMed
+ MyExpenses.nInsur;
nBalance = nInTotal - nExTotal;
cout<<"\nTotal Income : "<<>
cout<<"\nTotal Expenses : "<<>
if (nBalance<0)><>

No comments:

Post a Comment