CST 116 Austin Guertin 13a 11.7 pg 317 #5-6 (Statements for 5, Judgements for 6) 5) .cpp #include #include #include using namespace std; const int RECORDS = 100; const int MAX = 4; int main() { string records[RECORDS]; int num_records = 0; //Open the file ifstream inFile; ofstream outFile; inFile.open("C:\\TEMP\\13a_number5_data.txt"); outFile.open("C:\\TEMP\\13a_number5_report.txt"); //Check to see if file is open (a) if (inFile.is_open() && outFile.is_open()) { cout << "\n\n"; // Read until end of file is reached while (!inFile.eof()) { //Priming read (b) getline(inFile, records[num_records], ' '); cout << records[num_records]; outFile << records[num_records]; num_records++; } cout << "\n\n\n\n"; //close the file (c) inFile.close(); } else { cout << "ERROR: This file could not be opened for some reason\n\n"; return num_records; } } 13a_number5_data - Notepad lname1, id1, age lname2, id2, age lname3, id3, age lname4, id4, age lname5, id5, age lname6, id6, age 13a_number5_report - Notepad lname1,id1,age lname2,id2,age lname3,id3,age lname4,id4,age lname5,id5,age lname6,id6,age 6) a. False b. False c. True d. True e. True 13b 11.9 pg 323 #1 (Write a full program to call the function) .cpp #include #include using namespace std; int main() { ifstream input; double lineValue[100]; double median; int count = 1; input.open("C:\\TEMP\\median.txt"); if (input.fail()) { cout << "Input file opening failed. \n"; exit(1); } while (count < 100 && input >> lineValue[count]) { count++; } count = count - 1; if ((count % 2) == 0) { count = count / 2; median = ((lineValue[count + 1] + lineValue[count]) / 2); } else { count = ((count - 1) / 2) + 1; median = lineValue[count]; } cout << "The median is " << median << "." << endl; return 0; } median.txt 2 4 8 16 32 64 13c 11.13 pg 333-336 Excercise 1 Done Successfully, I have added the pictures Excercise 2 2)Removing a slash makes an error 4)This also creates an error 8)My code works now 11.14 pg 336-337 #1 .cpp #include #include #include #include using namespace std; //This is the main function int main() { //Opening the "workers" file for reading fstream fin("C:\\TEMP\\workers.txt", ios::in); string fname, lname, ssn; double wage, straightTimePay, OTPay, netPay; int hoursWorked, actualHours, OTHours; char status; //Printing neat header cout << "\n\n " << left << setw(18) << "Name" << left << setw(20) << "SSN"; cout << left << setw(8) << "Wage" << left << setw(18) << "Hours Worked" << left << setw(10) << "Status"; cout << left << setw(20) << "Straight time Pay" << left << setw(15) << "OT Pay" << left << setw(15) << "Net Pay"; //Loop till entire data is read while (fin.good()) { //Reading data into its respective variables fin >> fname >> lname >> ssn >> wage >> hoursWorked >> status; //calculating if there are any OT hours if (hoursWorked > 40) { //Splitting the hours actualHours = 40; OTHours = hoursWorked - 40; } else { actualHours = hoursWorked; OTHours = 0; } //Calculating employee straight time pay straightTimePay = actualHours * wage; //Calculating employee OT pay OTPay = OTHours * 1.5 * wage; //Calculating employee Net pay netPay = straightTimePay + OTPay; //determining if person is full time employee if (status == 'F') //Deducting the union fee netPay = netPay - 5; //Printing the record from "workers" cout << "\n\n " << left << setw(8) << fname << left << setw(10) << lname << left << setw(21) << ssn; cout << left << setw(12) << wage << left << setw(14) << hoursWorked << left << setw(15) << status; cout << left << setw(15) << straightTimePay << left << setw(15) << OTPay << left << setw(10) << netPay; } //Closing file fin.close(); cout << endl << endl; return 0; } workers.txt John Smith 123-09-8765 9.00 46 F Molly Brown 432-89-7654 9.50 40 F Tim Wheeler 239-34-3458 11.25 83 F Keil Wader 762-84-6543 6.50 35 P Trish Dish 798-65-9844 7.52 40 P Anthony Lei 934-43-9843 9.50 56 F Kevin Ashes 765-94-7343 4.50 30 P Cheryl Prince 983-54-9000 4.65 45 F Kim Cares 343-11-2222 10.00 52 F Dave Cockroach 356-98-1236 5.75 48 F Will Kusick 232-45-2322 15.00 45 P