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
|
#include <iostream>
#include <iomanip>
using namespace std;
struct Household
{
int idNumber;
int income;
int members;
};
char again;
int main()
{
do
{
//Displaying Survey Information
Household houses[13] = {{1041, 12180, 4}, {1062, 13240, 3}, {1327, 19800, 2},
{1483, 22458, 8}, {1900, 22458, 2}, {2112, 17000, 7},
{2345, 18125, 2}, {3210, 15623, 6}, {3600, 3200, 5},
{3601, 6500, 2}, {4724, 11970, 2}, {6217, 8900, 2},
{9280, 6200, 1}};
cout << "----------Household Survey----------" << endl << endl;
cout << "ID Number\tAnnual Income\tHousehold Members" << endl;
for (int i = 0; i < 13; ++i)
cout << houses[i].idNumber << "\t\t" << houses[i].income << "\t\t" << houses[i].members << endl;
//Average
int sum = 0;
double average = 0;
for (int i = 0; i < 13; ++i)
sum+=houses[i].income;
average = sum/13;
cout << "\n\n----------Average Income----------" << endl << endl;
cout << "The average income is: " << average << endl;
cout << "The following households exceed the average income: ";
if (houses->income > average)
{
cout << houses->idNumber << endl;
}
//Poverty Level
int povertyLevel = 0;
double povertyPercentage = 0;
povertyLevel = 6500 + (750 * houses->members);
if (houses->income < povertyLevel)
{
cout << houses->idNumber;
}
cout << "\n\n\n----------Poverty Level Statistics----------" << endl << endl;
cout << "Poverty Level = 6500 + 750 * Household Members" << endl;
cout << "The following households are below poverty level: " << endl << houses->idNumber << endl;
cout << povertyPercentage << "% of households are in poverty." << endl;
//Run again?
cout << "\nDo you want to run this program again? Y/N: ";
cin >> again;
cout << endl;
} while (again == 'y' || again == 'Y');
return 0;
}
|