aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schroeder <[email protected]>2021-11-20 17:26:38 -0800
committerBenjamin Schroeder <[email protected]>2021-11-20 17:26:38 -0800
commita574c65ed0ecd7e9eff0e355be90322eb7656592 (patch)
treee14e18a62297e83c349b52e393d056055446b8ca
parent11.7, 11.9, 11.13, 11.14 (diff)
downloadcst115-lab8-bensprogramma-a574c65ed0ecd7e9eff0e355be90322eb7656592.tar.xz
cst115-lab8-bensprogramma-a574c65ed0ecd7e9eff0e355be90322eb7656592.zip
update 11.14
-rw-r--r--CST116F2021-Lab8/11_13_Average_Data.txt1
-rw-r--r--CST116F2021-Lab8/CST116F2021-Lab8_Schroeder.cpp90
-rw-r--r--CST116F2021-Lab8/LAB_8_CODE_RUN and Answers for 11.7.txt106
3 files changed, 194 insertions, 3 deletions
diff --git a/CST116F2021-Lab8/11_13_Average_Data.txt b/CST116F2021-Lab8/11_13_Average_Data.txt
index 9cd3abb..6e68445 100644
--- a/CST116F2021-Lab8/11_13_Average_Data.txt
+++ b/CST116F2021-Lab8/11_13_Average_Data.txt
@@ -10,4 +10,5 @@
44
2
32
+57
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
+}
+
+*/
diff --git a/CST116F2021-Lab8/LAB_8_CODE_RUN and Answers for 11.7.txt b/CST116F2021-Lab8/LAB_8_CODE_RUN and Answers for 11.7.txt
index 1ba962d..21dfaa0 100644
--- a/CST116F2021-Lab8/LAB_8_CODE_RUN and Answers for 11.7.txt
+++ b/CST116F2021-Lab8/LAB_8_CODE_RUN and Answers for 11.7.txt
@@ -188,6 +188,110 @@ Submit: code & runs
pp. 336-337
10 pts #1
Submit: code & run
-
34 pts
+// ///////////////////////// CODE //////////////////////////////
+
+#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
+
+ 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
+}
+
+
+
+// ///////////////////////////////// RUN ////////////////////////
+
+
+ Name SSN# Wage Hours RegPay OT Status Net Pay
+
+John Smith 123-09-9765 $9.00 46 $360.00 $81.00 F $436.00
+Molly Brown 432-89-7654 $9.50 40 $380.00 $0.00 F $375.00
+Tim Wheeler 239-34-3458 $11.25 83 $450.00 $725.62 F $1170.62
+Keil Wader 762-84-6543 $6.50 35 $227.50 $0.00 P $227.50
+Trish Dish 798-65-9844 $7.52 40 $300.80 $0.00 P $300.80
+Anthony Lei 934-43-9843 $9.50 56 $380.00 $228.00 F $603.00
+Kevin Ashes 765-94-7343 $4.50 30 $135.00 $0.00 P $135.00
+Cheryl Prince 983-54-9000 $4.65 45 $186.00 $34.88 F $215.88
+Kim Cares 343-11-2222 $10.00 52 $400.00 $180.00 F $575.00
+Dave Cockroach 356-98-1236 $5.75 48 $230.00 $69.00 F $294.00
+Will Kusick 232-45-2322 $15.00 45 $600.00 $112.50 P $712.50
+
+C:\Users\Lenovo\Source\Repos\cst115-lab8-BensProgramma\x64\Debug\CST116F2021-Lab8.exe (process 9572) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+