From 9d53d8857eaa1c9405894a88ca75bc4657e42f35 Mon Sep 17 00:00:00 2001 From: msglm Date: Sat, 14 Jan 2023 05:31:48 -0600 Subject: Inital Commit --- C++/Final/Final Program Instruction (1).docx | Bin 0 -> 152126 bytes C++/Final/Final Program.cpp | 134 +++++++++++++++++++++++++++ C++/Final/Final Project Grade Sheet .pdf | Bin 0 -> 183679 bytes C++/Final/hourlyinput.txt | 10 ++ C++/Final/hourlyoutput.txt | 11 +++ 5 files changed, 155 insertions(+) create mode 100644 C++/Final/Final Program Instruction (1).docx create mode 100644 C++/Final/Final Program.cpp create mode 100644 C++/Final/Final Project Grade Sheet .pdf create mode 100644 C++/Final/hourlyinput.txt create mode 100644 C++/Final/hourlyoutput.txt (limited to 'C++/Final') 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 Binary files /dev/null and b/C++/Final/Final Program Instruction (1).docx 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 +#include +#include +#include + +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 Binary files /dev/null and b/C++/Final/Final Project Grade Sheet .pdf 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 -- cgit v1.2.3