write a C++ program. Write a program to read the survey results into a Vector, created in the class that contains the main function, and perform the following analysis. Do not use Arrays. You will not...


write a C++ program.


Write a program to read the survey results into a Vector, created in the class that contains the main function, and perform the following analysis. Do not use Arrays. You will not receive credit for Program 10 if you do.
a) Print the record of each household included in the survey in a four-column format with headings.
b) Calculate and print the average household income.
c) List the identification number, income, members, and state of the households that exceed the average in a four-column format with headings.
d) Determine and print the identification number, income, members, and state of the households, in a four-column format with headings, that have income below the 2021 United States poverty level.
e) Determine and print the percentage of households that have income below the 2021 United States poverty level.


Compute the poverty level income using one of the formulas below.
povertyLevel = 17420.00 + 4540.00 * (m – 2)
If household is in the 48 contiguous states or the District Of Columbia
povertyLevel = 21770.00 + 5680.00 * (m – 2)
If household is in the state of Alaska
povertyLevel = 20040,00 + 5220.00 * (m – 2)
If household is in the state of Hawaii


where m is the number of members of each household. This formula shows that the poverty level depends on the number of family members, m, and the poverty level income increases as m gets larger.


Create a Class named, HouseHold, in a header file named, HouseHold.h, and a source file named, HouseHold.cpp, that contain the attributes described earlier and other necessary member functions. Write a test Class named, Program10.cpp, that creates a Vector of HouseHold objects.


Here is the temple for Program10.cpp


#include
#include
#include
#include
#include


#include


#include "HouseHold.h"


using namespace std;


int openFiles(ifstream &, ofstream &);
void readFile(vector &, ifstream &);
double averageDataInVector(vector, int);
void aboveAverage(vector, double, int, ofstream &);
void belowPovertyLevel(vector, int, ofstream &);
void printDataInVector(vector, int, ofstream &);
void printRecord(int, double, int, string, ofstream &);


void closeFiles(ifstream &, ofstream &);
void holdScreen(int);
void developerInfo(ofstream &);


int main()
{
int rtnCode = 0;
int vectorSize = 0;
double average = 0.0;


ifstream inputFileObject; // create an input file object
ofstream outputFileObject; // create an input file object


rtnCode = openFiles(inputFileObject, outputFileObject);
if (rtnCode == 0)
{
outputFileObject <>
<>
<>


developerInfo(outputFileObject);


vector houseHold;
readFile(houseHold, inputFileObject);


vectorSize = houseHold.size();


printDataInVector(houseHold, vectorSize, outputFileObject);
average = averageDataInVector(houseHold, vectorSize);
aboveAverage(houseHold, average, vectorSize, outputFileObject);
belowPovertyLevel(houseHold, vectorSize, outputFileObject);
closeFiles(inputFileObject, outputFileObject);
holdScreen(1);
}
else
{
holdScreen(0);
}


return 0;
}
int openFiles(ifstream &inFileObject, ofstream &outFileObject)
{
int rc = 1;
inFileObject.open("Program10.txt"); // open the file for read
if (!inFileObject.fail())
{
outFileObject.open("Program10-output.txt"); // open the file for write
if (!outFileObject.fail())
{
rc = 0;
}
else
{
cout < "unable="" to="" create="" output="" file="" \"program10-output.txt\"="" "=""><>
}
}
else
{
cout < "file="" \"program10.txt\"="" "="">< "was="" not="" found."=""><>
}


return rc;
}


void readFile(vector &houseHold, ifstream &inFileObject)
{
int rc = 0;
int tempId;
double tempIncome;
int tempMembers;
string tempState;


inFileObject >> tempId // read first data
>> tempIncome
>> tempMembers
>> tempState;


while (!inFileObject.eof()) // if data is not end-of-file
{
HouseHold family(tempId, tempIncome, tempMembers, tempState);
houseHold.push_back(family);


inFileObject >> tempId // read the next data
>> tempIncome
>> tempMembers
>> tempState;
}
}


double averageDataInVector(vector houseHold, int theSize)
{


}


void aboveAverage(vector houseHold, double theAverage, int theSize, ofstream &outFile)
{


}


void belowPovertyLevel(vector houseHold, int theSize, ofstream &outFile)
{


}


void printDataInVector(vector houseHold, int theSize, ofstream &outFile)
{


}


void printRecord(int theId, double theIncome, int theMembers, string theState, ofstream &outFile)
{


}


void holdScreen(int theFlag)
{
char ch;


if (theFlag)
cout < "\noutput="" sent="" to="" \"program10-output.txt\".="" press="" any="" key="" to="" exit...="">
else
cout < "\npress="" any="" key="" to="" exit...="">


ch = getch();
cout <>
}


void developerInfo(ofstream &outputFileObject)
{
outputFileObject < "name:="" reshma="" kumar"=""><>
outputFileObject < "course:="" cosc-1337="" programming="" fundamentals="" ii"=""><>
outputFileObject < "program:="">
<>
<>
} // End of developerInfo


void closeFiles(ifstream &inFileObject, ofstream &outFileObject)
{
inFileObject.close();
outFileObject.close();
}


Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here