diff options
Diffstat (limited to 'CST116F2021-Lab8/CST116F2021-Lab8_Schroeder.cpp')
| -rw-r--r-- | CST116F2021-Lab8/CST116F2021-Lab8_Schroeder.cpp | 90 |
1 files changed, 88 insertions, 2 deletions
diff --git a/CST116F2021-Lab8/CST116F2021-Lab8_Schroeder.cpp b/CST116F2021-Lab8/CST116F2021-Lab8_Schroeder.cpp index bdab3ec..defb720 100644 --- a/CST116F2021-Lab8/CST116F2021-Lab8_Schroeder.cpp +++ b/CST116F2021-Lab8/CST116F2021-Lab8_Schroeder.cpp @@ -19,7 +19,8 @@ int main() ifstream inFile; FILE* inPtr; // open the file - fopen_s(&inPtr, "C:\\Users\\Lenovo\\source\\repos\\cst115-lab8-BensProgramma\\CST116F2021-Lab8\\11_13_Average_Data.txt", "r"); + //fopen_s(&inPtr, "C:\\Users\\Lenovo\\source\\repos\\cst115-lab8-BensProgramma\\CST116F2021-Lab8\\11_13_Average_Data.txt", "r"); + fopen_s(&inPtr, "11_13_Average_Data.txt", "r"); int inInt; // read the file if (inPtr != 0) @@ -82,9 +83,94 @@ int main() // /////////////////////// 11.13 Debugging Exercises pp 333 - 336 ///////////////////// +/* + + + +*/ + +// //////////////////////// 11.14 Programming Exercise pp336 -337 ////////////////////// +/* +#include <iostream> +#include <fstream> +#include <string> +#include <iomanip> +using namespace std; + +int main() +{ + + char first[100]{}; + char last[100]{}; + char ssn[12]{}; + float wage =0; + int hours = 0; + char status; + int count = 1; + int num_records = 0; + + float dues = 0.00; + int OThours = 0; + float STPay = 0.00; + float OTPay = 0.00; + float NetPay = 0.00; + ifstream fin; + //fin.open("C:\\Users\\Lenovo\\source\\repos\\cst115-lab8-BensProgramma\\CST116F2021-Lab8\\11_14_Data.txt"); + fin.open("11_14_Data.txt"); //open the file -// ////////////////////// 11.14 Programming Exercise pp336 - 337 ////////////////// + cout << " Name\t\t SSN#\tWage\t Hours\tRegPay\t\t OT\t Status\tNet Pay\n" << endl; //Output Table Header + + while (fin && !fin.eof()) + { + fin >> first; // Read the file + fin >> last; + fin >> ssn; + fin >> wage; + fin >> hours; + fin >> status; + num_records++; + + OThours = 0; //Calculate Overtime if needed + if (hours> 40) + { + OThours = hours - 40; + hours = hours - OThours; + } + STPay = wage * hours; + OTPay = wage * (1.5 * OThours); + hours = hours + OThours; + + dues = 5.00; //Calculate Union Dues + if (status=='P') + { + dues = 0.00; + } + + NetPay = STPay + OTPay - dues; //Calculate Net Pay + + + if ( num_records<12) //Print out Table + { + cout << first << " " + << last << "\t" + << ssn << "\t$" + << fixed << setprecision(2)<< wage << "\t\t" + << hours << "\t$" + << fixed << setprecision(2) << STPay << "\t\t$" + << fixed << setprecision(2) << OTPay << "\t\t" + << status << "\t" + << "$" << fixed << setprecision(2) << NetPay << endl; + count++; + + } + + } + + fin.close(); //Close the file +} + +*/ |