PFB cpp code for the given problem #include #include #include #include #include #include using namespace std; string StringPadding(string original, int charCount ) { original.resize( charCount, \' \' ); return original; } class Song { public : string date; int wk; string song; char Cat; string artist; Song(string d, int w, string s, char c, string a) { date = d; wk = w; song = s; Cat = c; artist = a; } }; int main() { //FILE *fp = freopen(\"input.txt\", \"r\", stdin); ifstream fp; char *fileName = \"input.txt\"; fp.open(fileName); if( !fp ) { cout<<\"\ input file not found \ \"; cout<<\"\ Press any key, and enter to terminate and exit the program\ \"; return 0; } int noLinesRead = 0; string date=\"\", song=\"\", artist=\"\"; int wk; char cat; vector vec; int maxSongLen = 0, maxArtistLen = 0; while(fp){ fp >> date >> wk; getline(fp, song); if(song.length() > maxSongLen) maxSongLen = song.length(); fp >> cat; getline(fp, artist); if(artist.length() > maxArtistLen) maxArtistLen = artist.length(); Song sObj = Song(date, wk, song, cat, artist); vec.push_back(sObj); } int maxLengthToBePadded = maxArtistLen + maxSongLen + 17; string strForEqualSign(\'=\', maxLengthToBePadded); string strForMinusSign(\'-\', maxLengthToBePadded); int totalSongs = vec.size(); int femaleArtist = 0; int maleArtist = 0; int groupArtist = 0; float avgWeeks = 0; int totWeeks = 0; /* cout << right << StringPadding(\"Date\", 6) << StringPadding(\"Week\", 5) << StringPadding(\"Song\", maxSongLen+1) << StringPadding(\"Cat\", 4) << StringPadding(\"Artist\", maxArtistLen) << endl; */ cout << setw(5) << right << \"Date\" << setw(5) << right << \"Week\" << setw(maxSongLen/2) << right << \"Song\" << setw(maxSongLen/2 + 1) << right << \" \" << setw(4) << right << \"Cat\" << setw(maxArtistLen/2) << right << \"Artist\" << endl; cout << strForEqualSign << endl; for(int i=0; i Solution PFB cpp code for the given problem #include #include #include #include #include #include using namespace std; string StringPadding(string original, int charCount ) { original.resize( charCount, \' \' ); return original; } class Song { public : string date; int wk; string song; char Cat; string artist; Song(string d, int w, string s, char c, string a) { date = d; wk = w; song = s; Cat = c; artist = a; } }; int main() { //FILE *fp = freopen(\"input.txt\", \"r\", stdin); ifstream fp; char *fileName = \"input.txt\"; fp.open(fileName); if( !fp ) { cout<<\"\ input file not found \ \"; cout<<\"\ Press any key, and enter to terminate and exit the program\ \"; return 0; } int noLinesRead = 0; string date=\"\", song=\"\", artist=\"\"; int wk; char cat; vector vec; int maxSongLen = 0, maxArtistLen = 0; while(fp){ fp >> date >> wk; getline(fp, song); if(song.length() > maxSongLen) maxSongLen = song.length(); fp >> cat; getline(fp, artist); if(artist.length() > maxArtistLen) maxArtistLen = artist.length(); Song sObj = Song(date, wk, song, cat, artist); vec.push_back(sObj); } int maxLengthToBePadded = maxArtistLen + max.