Question: #include #include #include #include #include #include using namespace std; int main() { ifstream fin(data.txt); cout while (!fin.eof()) { string county,demographic; string ct; double kl,ln,mb,nd; getline(fin,county,'
#include
#include
#include
#include
#include
#include
usingnamespacestd;
intmain()
{
ifstream fin("data.txt");
cout
while(!fin.eof())
{
string county,demographic;
string ct;
doublekl,ln,mb,nd;
getline(fin,county,' ');
getline(fin,demographic,' ');
demographic+='\t';
getline(fin,ct);
istringstream iss(ct);
iss>>kl>>ln>>mb>>nd;
cout
}
fin.close();
return0;
}
output------
Country Demographic % Fully % Partially Vaccinated Vaccinated
Alameda 12-17 54.9 62.6
Alameda 18-49 76.1 83.5
Alameda 50-64 78.1 84.2
Alameda 65+ 70.5 76.3
Alameda American Indian or Alaska Native 72.9 83.3
Alameda Asian 93.6 100.9
Alameda Black or African American 45.3 50.0
Alameda Latino 48.2 54.4
Alameda Multiracial 29.7 31.3
Alameda Native Hawaiian or Other Pacific Islander 69.3 76.7
Program ended with exit code: 0
Professor said,
1)kl,ln,mb,nd; These are NOT descriptive variable names. Change to descriptive ones.
2) All output is supposed to be directed to a file.
3) Output is not lined up. This is because you used tabs instead of setw() and because strings must be 'left' justified and numbers 'right' justified.
4) If the divisor is zero you just assign a zero to the quotient. Divisioin by zero is undefined.
5) You completelu omitted the requirement: "Call exactly one function from within loop to compute percentages. This one function is to compute both percentages."
I don't know what I have to fix, can you guys do it for me? it's c++
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
