#include <iostream>
#include <iomanip>
#include <fstream>
const int NUM_SURVEY=3;
using namespace std;
struct Survey
{
int IdentificationNumber;
double annualIncome;
int numberOfHouseMember;
};
void getData();
void calculateAverage();
void findPoverty();
void printReport();
int main()
{
getData();
calculateAverage();
findPoverty();
printReport();
system("pause");
return 0;
}
void getData()
{
Survey Households[NUM_SURVEY];
int i;
cout<<"------------Enter " << NUM_SURVEY<<" Household Data.-----------------\n";
cout<<endl;
for(i=0;i<NUM_SURVEY;i++)
{
//Get Identification
cout<<"Enter Family "<<(i+1)<<" data.\n"<<endl;
cout<<"Enter Identification Number "<<": ";
cin>>Households[i].IdentificationNumber;
//Get annuall income
cout<<"Enter Annual Income "<<": RM ";
cin>>Households[i].annualIncome;
//Get number of house member
cout<<"Enter member of House "<<": ";
cin>>Households[i].numberOfHouseMember;
cout<<endl;
}
}
void calculateAverage()
{
Survey Households[NUM_SURVEY];
int i;
cout<<"The average of Houshold income is:\n";
cout<< fixed << showpoint <<setprecision(2);
for(i=0;i<NUM_SURVEY;i++)
{
double average;
average=Households[i].annualIncome/Households[i].numberOfHouseMember;
cout<<"Average Household Income Family "<<(i+1)<<": RM"<<average;
cout<<endl;
}
}
void findPoverty()
{
Survey Households[NUM_SURVEY];
int i;
cout<<"\nThe poverty level is :\n";
cout<< fixed << showpoint <<setprecision(2);
for(i=0;i<NUM_SURVEY;i++)
{
double p;
p=7000+850*(Households[i].numberOfHouseMember-2);
cout<<"Percentage of poverty Family "<<(i+1)<<": RM"<<p<<endl;
}
}
void printReport()
{
Survey Households[NUM_SURVEY];
int i;
cout<<"\n----------------------Survey of Household Income Report----------------------\n\n";
cout<<setw(25)<<"Identification Number"
<<setw(25)<<"Annual Income "
<<setw(25)<<"Household Member\n";
cout<<"_____________________________________________________________________________"<<endl;
cout<< fixed << showpoint <<setprecision(2);
for(i=0;i<NUM_SURVEY;i++)
{
cout<<setw(15)<<Households[i].IdentificationNumber
<<setw(30)<<Households[i].annualIncome
<<setw(20)<<Households[i].numberOfHouseMember<<endl;
}
cout<<endl;
for(i=0;i<NUM_SURVEY;i++)
{
double p;
p=7000+850*(Households[i].numberOfHouseMember-2);
cout<<"Percentage of poverty Family "<<(i+1)<<": RM"<<p<<endl;
}
}
rezonk 0 Newbie Poster
abdelhakeem 0 Forever Learning
rezonk 0 Newbie Poster
abdelhakeem 0 Forever Learning
abdelhakeem 0 Forever Learning
ravenous 266 Posting Pro in Training
rezonk 0 Newbie Poster
abdelhakeem 0 Forever Learning
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.