Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Why is my last switch giving me red lines? #include MainProgram.h #include DonationRecord.h #include #include #include #include #include using namespace std; vector readDonationsFromFile
Why is my last switch giving me red lines? #include "MainProgram.h #include "DonationRecord.h #include #include #include #include #include using namespace std; vector readDonationsFromFileconst string& filename vector donations; ifstream filefilename; if file.isopen cerr "Sorry, cannot open file." endl; return donations; string line; Skip header getlinefile line; while getlinefile line stringstream ssline; string token; vector tokens; while getliness token, tokens.pushbacktoken; if tokenssize donations.emplacebacktokens tokens tokens tokens tokens tokens stoftokens; file.close; return donations; void displayHeading cout "United Cause Relief Agency Daily Donations" endl; cout endl; cout "Gift IDtCompanytPhonetPOCtItem DonatedtCategorytValue endl; cout endl; void displayMenu cout "United Cause Relief Agency Daily Donations Reports Menu" endl; cout endl; cout : All by Natural Order of Input File" endl; cout : All by Company name, Ascending" endl; cout : All by Company name, Descending" endl; cout : All by Category, Ascending" endl; cout : All by Gift ID Ascending" endl; cout : One Donor only by Value, Descending" endl; cout : Exit the program" endl; cout "Please select report you wish to be run from menu above : ; void sortByGiftIDvector& donations sortdonationsbegin donations.end; void sortByCompanyNameAscendingvector& donations sortdonationsbegin donations.endconst DonationRecord& a const DonationRecord& b return agetDonorName bgetDonorName; ; void sortByCompanyNameDescendingvector& donations sortdonationsbegin donations.endconst DonationRecord& a const DonationRecord& b return agetDonorName bgetDonorName; ; void sortByCategoryAscendingvector& donations sortdonationsbegin donations.endconst DonationRecord& a const DonationRecord& b return agetItemCategory bgetItemCategory; ; void generateReportconst vector& donations, int choice vector sortedDonations donations; switch choice case : displayHeading; for const auto& donation : sortedDonations donation.displayRecord; break; case : sortByCompanyNameAscendingsortedDonations; break; case : sortByCompanyNameDescendingsortedDonations; break; case : sortByCategoryAscendingsortedDonations; break; case : sortByGiftIDsortedDonations; break; case : string donorName; cout "Enter donor name: ; cin donorName; vector filteredDonations; for const auto& donation : donations if donationgetDonorName donorName filteredDonations.pushbackdonation; sortfilteredDonationsbegin filteredDonations.endconst DonationRecord& a const DonationRecord& b return agetValue bgetValue; ; displayHeading; for const auto& donation : filteredDonations donation.displayRecord; break; default: cout "Sorry your choice was not recognized. Please try again." endl; return; Return to avoid further processing float total ; for const auto& donation : sortedDonations total donation.getValue; cout "Total" ttttttt$ total endl; int main vector donations readDonationsFromFileDonationscsv; int choice; do displayMenu; cin choice; switch choice case : case : case :
Why is my last switch giving me red lines?
#include "MainProgram.h
#include "DonationRecord.h
#include
#include
#include
#include
#include
using namespace std;
vector readDonationsFromFileconst string& filename
vector donations;
ifstream filefilename;
if file.isopen
cerr "Sorry, cannot open file." endl;
return donations;
string line;
Skip header
getlinefile line;
while getlinefile line
stringstream ssline;
string token;
vector tokens;
while getliness token,
tokens.pushbacktoken;
if tokenssize
donations.emplacebacktokens tokens tokens tokens tokens tokens stoftokens;
file.close;
return donations;
void displayHeading
cout "United Cause Relief Agency Daily Donations" endl;
cout endl;
cout "Gift IDtCompanytPhonetPOCtItem DonatedtCategorytValue endl;
cout endl;
void displayMenu
cout "United Cause Relief Agency Daily Donations Reports Menu" endl;
cout endl;
cout : All by Natural Order of Input File" endl;
cout : All by Company name, Ascending" endl;
cout : All by Company name, Descending" endl;
cout : All by Category, Ascending" endl;
cout : All by Gift ID Ascending" endl;
cout : One Donor only by Value, Descending" endl;
cout : Exit the program" endl;
cout "Please select report you wish to be run from menu above : ;
void sortByGiftIDvector& donations
sortdonationsbegin donations.end;
void sortByCompanyNameAscendingvector& donations
sortdonationsbegin donations.endconst DonationRecord& a const DonationRecord& b
return agetDonorName bgetDonorName;
;
void sortByCompanyNameDescendingvector& donations
sortdonationsbegin donations.endconst DonationRecord& a const DonationRecord& b
return agetDonorName bgetDonorName;
;
void sortByCategoryAscendingvector& donations
sortdonationsbegin donations.endconst DonationRecord& a const DonationRecord& b
return agetItemCategory bgetItemCategory;
;
void generateReportconst vector& donations, int choice
vector sortedDonations donations;
switch choice
case :
displayHeading;
for const auto& donation : sortedDonations
donation.displayRecord;
break;
case :
sortByCompanyNameAscendingsortedDonations;
break;
case :
sortByCompanyNameDescendingsortedDonations;
break;
case :
sortByCategoryAscendingsortedDonations;
break;
case :
sortByGiftIDsortedDonations;
break;
case :
string donorName;
cout "Enter donor name: ;
cin donorName;
vector filteredDonations;
for const auto& donation : donations
if donationgetDonorName donorName
filteredDonations.pushbackdonation;
sortfilteredDonationsbegin filteredDonations.endconst DonationRecord& a const DonationRecord& b
return agetValue bgetValue;
;
displayHeading;
for const auto& donation : filteredDonations
donation.displayRecord;
break;
default:
cout "Sorry your choice was not recognized. Please try again." endl;
return; Return to avoid further processing
float total ;
for const auto& donation : sortedDonations
total donation.getValue;
cout "Total" ttttttt$ total endl;
int main
vector donations readDonationsFromFileDonationscsv;
int choice;
do
displayMenu;
cin choice;
switch choice
case :
case :
case :
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started