summaryrefslogtreecommitdiffstats
path: root/C++/Final
diff options
context:
space:
mode:
authormsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
committermsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
commit9d53d8857eaa1c9405894a88ca75bc4657e42f35 (patch)
treeeb1efc1d028b949dd83bb710c68be8eff58f26e7 /C++/Final
downloadschool-code-master.tar.gz
school-code-master.tar.bz2
school-code-master.zip
Inital CommitHEADmaster
Diffstat (limited to 'C++/Final')
-rw-r--r--C++/Final/Final Program Instruction (1).docxbin0 -> 152126 bytes
-rw-r--r--C++/Final/Final Program.cpp134
-rw-r--r--C++/Final/Final Project Grade Sheet .pdfbin0 -> 183679 bytes
-rw-r--r--C++/Final/hourlyinput.txt10
-rw-r--r--C++/Final/hourlyoutput.txt11
5 files changed, 155 insertions, 0 deletions
diff --git a/C++/Final/Final Program Instruction (1).docx b/C++/Final/Final Program Instruction (1).docx
new file mode 100644
index 0000000..330ee70
--- /dev/null
+++ b/C++/Final/Final Program Instruction (1).docx
Binary files differ
diff --git a/C++/Final/Final Program.cpp b/C++/Final/Final Program.cpp
new file mode 100644
index 0000000..e257f12
--- /dev/null
+++ b/C++/Final/Final Program.cpp
@@ -0,0 +1,134 @@
+// Name: msglm
+// Date: 4/29/2022
+// Title: Payroll Calculator
+// Description: Takes input data from file deliminated by a space. This information is then used to calculate taxes, net, and gross pay for each person in the entry.
+
+#include <iostream>
+#include <string>
+#include <fstream>
+#include <iomanip>
+
+using namespace std;
+
+// Named constants
+int ARRAY_SIZE = 10;
+double FED_TAX=0.09;
+double STATE_TAX=0.05;
+double FICA_TAX=0.062;
+
+
+// Function prototype
+double GrossPay(double x, double y);
+double Tax(double x);
+
+// Main function--------------------------------------------------------------
+int main()
+{
+ // Declare Varibles
+ string lName[ARRAY_SIZE];
+ string fName[ARRAY_SIZE];
+ string fullName;
+ double payrate[ARRAY_SIZE];
+ double hours[ARRAY_SIZE];
+ double grossPay[ARRAY_SIZE];
+ double netPay[ARRAY_SIZE];
+ double taxesOwed[ARRAY_SIZE];
+ double totalGrossPay;
+ double totalTaxes;
+ double totalNetPay;
+
+ // Declare variables for files
+ ifstream inputFile;
+ ofstream outputFile;
+
+ // Open files
+ inputFile.open("hourlyinput.txt");
+ outputFile.open("hourlyoutput.txt");
+
+
+
+
+ // Print grogram title and description
+ cout << "Title: Payroll Calculator" << endl << "Description: Takes input data from file deliminated by a space. This information is then used to calculate taxes, net, and gross pay for each person in the entry." << endl;
+
+
+ // check to make sure input file opened
+ if (inputFile) {
+ cout << "Successfully opened file";
+ } else {
+ cout << "ERROR! File failed to open!";
+ return 1;
+ }
+
+ // Collect data from the file (Parallel Arrays)
+
+ for (int i = 0; i < ARRAY_SIZE; i++) {
+ inputFile >> fName[i] >> lName[i] >> payrate[i] >> hours[i];
+
+
+ // Calculate Gross pay for all employees and store in arrays
+ grossPay[i] = GrossPay(hours[i], payrate[i]);
+
+
+ // Calculate taxes for all employees and store in arrays
+
+ taxesOwed[i] = Tax(grossPay[i]);
+
+
+
+ // Calculate net pay for each employee and store in arrays
+
+ netPay[i] = grossPay[i] - taxesOwed[i];
+ }
+
+ // Printing payroll report to an OUTPUT FILE
+
+ outputFile << fixed << left << showpoint << setprecision(2);
+ outputFile << setw(17) << "Name" << setw(13) << "Payrate" << setw(9) << "Hours" << setw(9) << "Gross" << setw(9) << "Taxes" << setw(9) << "Net" << endl;
+ for (int i = 0; i < ARRAY_SIZE; i++) {
+ fullName = fName[i] + " " + lName[i];
+ outputFile << setw(17) << fullName << setw(13) << payrate[i] << setw(9) << hours[i] << setw(9) << grossPay[i] << setw(9) << taxesOwed[i] << setw(9) << netPay[i] << endl;
+ }
+
+ cout << "Outputted to file.";
+
+ // Print payroll statistics to the SCREEN
+
+ for (int i = 0; i < ARRAY_SIZE; i++)
+ {
+ totalGrossPay = totalGrossPay + grossPay[i];
+ totalTaxes = totalTaxes + taxesOwed[i];
+ totalNetPay = totalNetPay + netPay[i];
+ }
+ cout << "Weekly Payroll Statistics:\n\n" ;
+ cout << "Total Gross Pay: " << totalGrossPay << endl;
+ cout << "Total Taxes: " << totalTaxes << endl;
+ cout << "Total Net Pay: " << totalNetPay << endl;
+
+
+
+ // Close files
+ outputFile.close();
+ inputFile.close();
+
+
+ return 0;
+}
+
+// Function definations
+
+double GrossPay(double payRateValue, double hours)
+{
+
+return payRateValue*hours;
+
+}
+
+double Tax(double grossPayValue)
+{
+ double FICAOwed = grossPayValue * FICA_TAX;
+ double stateOwed = grossPayValue * STATE_TAX;
+ double fedOwed = grossPayValue * FED_TAX;
+ double totalTax = FICAOwed + stateOwed + fedOwed;
+ return totalTax;
+}
diff --git a/C++/Final/Final Project Grade Sheet .pdf b/C++/Final/Final Project Grade Sheet .pdf
new file mode 100644
index 0000000..e7227f4
--- /dev/null
+++ b/C++/Final/Final Project Grade Sheet .pdf
Binary files differ
diff --git a/C++/Final/hourlyinput.txt b/C++/Final/hourlyinput.txt
new file mode 100644
index 0000000..cad5cdf
--- /dev/null
+++ b/C++/Final/hourlyinput.txt
@@ -0,0 +1,10 @@
+Anders Alex 13.25 37.5
+Botch Beth 11.25 35.5
+Cross Brian 14.50 38
+Doe John 15.75 35
+Eyre Jane 20.00 40
+Falls Frank 18.50 39
+Gall George 17.00 25
+Hicks Heath 13.75 38
+Jacob John 15.50 33
+Ihle Ike 16.50 37 \ No newline at end of file
diff --git a/C++/Final/hourlyoutput.txt b/C++/Final/hourlyoutput.txt
new file mode 100644
index 0000000..491e315
--- /dev/null
+++ b/C++/Final/hourlyoutput.txt
@@ -0,0 +1,11 @@
+Name Payrate Hours Gross Taxes Net
+Anders Alex 13.25 37.50 496.88 100.37 396.51
+Botch Beth 11.25 35.50 399.38 80.67 318.70
+Cross Brian 14.50 38.00 551.00 111.30 439.70
+Doe John 15.75 35.00 551.25 111.35 439.90
+Eyre Jane 20.00 40.00 800.00 161.60 638.40
+Falls Frank 18.50 39.00 721.50 145.74 575.76
+Gall George 17.00 25.00 425.00 85.85 339.15
+Hicks Heath 13.75 38.00 522.50 105.55 416.95
+Jacob John 15.50 33.00 511.50 103.32 408.18
+Ihle Ike 16.50 37.00 610.50 123.32 487.18