# include # include # include # include # include # include # include #include #include using namespace std; char displayMenu(); void inputFile (string fileName,vector &gender, vector &age, vector...

C++ Assignment Level 1I should be able to open and edit this source code on my MacBook. I have attached the detailed instructions and my detailed initial source code.


# include # include # include # include # include # include # include #include #include using namespace std; char displayMenu(); void inputFile (string fileName,vector&gender, vector&age, vector&totalCholesterol, vector&hdl, vector&sbp,vector&treatmentForHypertension, vector&\ smokingStatus); void inputConsole (vector&gender,vector&age, vector&totalCholesterol, vector&hdl, vector&sbp,vector&treatmentForHypertension, vector&smokingStatus)\ ; void printAllRisks (vector&gender,vector&age, vector&totalCholesterol, vector&hdl, vector&sbp,vector&treatmentForHypertension, vector&smokingStatus\ ,vector&risk); bool clearAllVectors (vector&gender,vector&age, vector&totalCholesterol, vector&hdl, vector&sbp,vector&treatmentForHypertension, vector&smokingStat\ us,vector&risk); void finalRisk (vector&gender ,vector&age, vector&totalCholesterol, vector&hdl, vector&sbp,vector&treatmentForHypertension, vector&smokingStatus); int main () { // Defining all the variables char optionSelected; vector gender; vector age; vector totalCholesterol; vectorhdl; vector sbp; vectortreatmentForHypertension; vectorsmokingStatus; vectorrisk; const int MINAGE = 20; const int MAXAGE = 79; ifstream infile; string fileName; optionSelected=displayMenu(); while (optionSelected!='5') { switch (optionSelected){ case '1': { inputFile(fileName,gender,age,totalCholesterol,hdl,sbp,treatmentForHypertension,smokingStatus); finalRisk(gender,age,totalCholesterol,hdl,sbp,treatmentForHypertension,smokingStatus); break;} case '2': { inputConsole(gender,age,totalCholesterol,hdl,sbp,treatmentForHypertension,smokingStatus); finalRisk(gender,age,totalCholesterol,hdl,sbp,treatmentForHypertension,smokingStatus); break;} case '3': printAllRisks(gender,age,totalCholesterol,hdl,sbp,treatmentForHypertension,smokingStatus,risk); break; case '4': clearAllVectors(gender,age,totalCholesterol,hdl,sbp,treatmentForHypertension,smokingStatus,risk); break; } } return 0; } // MENU char displayMenu() { char optionBeforeValidation; // Displaying the menu cout<"1. input="" file"="">< endl="">< "2.="" input="" console"="">< endl="">< "3.="" display="" all="" risks"="">< endl="">< "4.="" clear="" all="">< endl="">< "5.="" exit"="">< endl="">< "please="" type="" the="" number="" of="" the="" desired="" option:"="" ;="" choosing="" the="" option="" cin="">> optionBeforeValidation; //Validating the option while (optionBeforeValidation!='5'&&optionBeforeValidation!='4' &&optionBeforeValidation!='3'&&optionBeforeValidation!='2'&& optionBeforeValidation!='1') { cout <"this is="" not="" an="" available="" option.="" "="">< endl=""><"1. input="" file"="">< endl="">< "2.="" input="" console"=""><><"3. display="" all="" risks"="">< endl="">< "4.="" clear="" all="">< endl="">< "5.="" exit"="">< "please="" type="" the="" number="" of="" the="" desired="" option:="" "="" ;="" cin="">> optionBeforeValidation; } return optionBeforeValidation; } // OPTION 1 : INPUT FILE void inputFile(string fileName,vector&gender,vector&age, vector&totalCholesterol, vector&hdl, vector&sbp,vector&treatmentForHypertension, vector&sm\ okingStatus) { int lineNumber=0; ifstream infile; string line; const int MINAGE=20; const int MAXAGE=79; cout< "input="" file="" name:="" ";="" cin="">>fileName; infile.open (fileName.c_str()); if (!infile) cout<"this file="" couldn't="" be="" opened.";="" else="" {getline(infile,line);="" while(getline(infile,="" line));="" {stringstream="" ss="" (line+'n');="" gender="" ss="">>ws; if (line.empty()||(line!="m"&&line!="M"&&line!="male"&& line!="Male"&&line!="f"&&line!="F" &&line!="female"&&line!="Female")) {cout<"invalid gender on gender="">
Jul 25, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here