Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Print out the persons and their scores from both files Each output line is last

ID: 441908 • Letter: P

Question

  1. Print out the persons and their scores from both files
    1. Each output line is last name, "," , first name andscore
    2. Linesappear in ascending order by last name, then first name
output should display in ascending order using two text files. this is what i have so far Astaire, Estelle 88
Astaire, Fred 79
Lamb, Elia 77
Lincoln, Abe 88
Saramago, Jose 95
Shelley, Mary 77
Zola, Emile 99

#include <iostream>
using namespace std;
#include <fstream>
#include <cstdlib>
#include <string> struct person
{
string first, last;
int score;
};
int main()
{ ifstream data1, data2; data1.open("data1.txt");
if(!data1)
{
cerr << "Error: data1 could not be opened" << endl;
exit(1);
} data2.open("data2.txt"); // opens the file
if(!data2) // file couldn't be opened
{
cerr << "Error: data2 could not be opened" << endl;
exit(2);
} person rec1;
data1 >> rec1.first >> rec1.last >> rec1.score;
while (!data1.eof())
{
cout << rec1.last << ", " << rec1.first << " " << rec1.score << endl;
data1 >> rec1.first >> rec1.last >> rec1.score;
} person rec2;
data2 >> rec2.first >> rec2.last >> rec2.score;
while (!data2.eof())
{
cout << rec2.last << ", " << rec2.first << " " << rec2.score << endl;
data2 >> rec2.first >> rec2.last >> rec2.score;
} data1.close();
data2.close();
return 0;
}
  1. Print out the persons and their scores from both files
    1. Each output line is last name, "," , first name andscore
    2. Linesappear in ascending order by last name, then first name
output should display in ascending order using two text files. this is what i have so far Astaire, Estelle 88
Astaire, Fred 79
Lamb, Elia 77
Lincoln, Abe 88
Saramago, Jose 95
Shelley, Mary 77
Zola, Emile 99
output should display in ascending order using two text files. this is what i have so far Astaire, Estelle 88
Astaire, Fred 79
Lamb, Elia 77
Lincoln, Abe 88
Saramago, Jose 95
Shelley, Mary 77
Zola, Emile 99

#include <iostream>
using namespace std;
#include <fstream>
#include <cstdlib>
#include <string> struct person
{
string first, last;
int score;
};
int main()
{ ifstream data1, data2; data1.open("data1.txt");
if(!data1)
{
cerr << "Error: data1 could not be opened" << endl;
exit(1);
} data2.open("data2.txt"); // opens the file
if(!data2) // file couldn't be opened
{
cerr << "Error: data2 could not be opened" << endl;
exit(2);
} person rec1;
data1 >> rec1.first >> rec1.last >> rec1.score;
while (!data1.eof())
{
cout << rec1.last << ", " << rec1.first << " " << rec1.score << endl;
data1 >> rec1.first >> rec1.last >> rec1.score;
} person rec2;
data2 >> rec2.first >> rec2.last >> rec2.score;
while (!data2.eof())
{
cout << rec2.last << ", " << rec2.first << " " << rec2.score << endl;
data2 >> rec2.first >> rec2.last >> rec2.score;
} data1.close();
data2.close();
return 0;
}

Explanation / Answer

#include #include using namespace std; bool isVowel(char character); string substr(string line); int main() { string line; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote