Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * CIS 22A
- * Wages Lab - lab1.cpp
- * ~ Calculates wages and amount of taxes
- *
- * @author Minhduc Cao
- * @version 1.1
- * @since 10.17.17
- */
- #include <iostream>
- #include <iomanip>
- using namespace std;
- double hours, dependents, grossPay, netPay;
- double securityTax, incomeTax, stateTax, insuranceTax;
- double const unionTax = 10;
- double const payrate = 16.78;
- // Calculates the gross pay amount
- void calculateGross() {
- if (hours <= 40) {
- grossPay = hours * payrate;
- }
- else {
- grossPay = hours * payrate;
- double overtimeHours = hours - 40;
- grossPay += overtimeHours * payrate * 1.5;
- }
- }
- // Calculates the net pay amount and any other tax amounts
- void calculateNet() {
- netPay = grossPay;
- securityTax = netPay * 0.06;
- netPay -= securityTax;
- incomeTax = netPay * 0.14;
- netPay -= incomeTax;
- stateTax = netPay * 0.05;
- netPay -= stateTax;
- netPay -= unionTax;
- if (dependents >= 3)
- {
- insuranceTax = 35;
- netPay -= insuranceTax;
- }
- }
- // Asks the user for # of hours and # of dependents, calculates the gross and net pay
- // Displays the pay amounts and tax amounts
- int main() {
- cout << "Enter the # of hours worked: " << endl;
- cin >> hours;
- cout << "Enter the # of dependents: " << endl;
- cin >> dependents;
- calculateGross();
- calculateNet();
- // Sets the precision of data values to properly represent money values
- cout << fixed;
- cout << setprecision(2);
- cout << endl << "Gross Pay: $" << grossPay << endl;
- cout << "Social Security Tax: $" << securityTax << endl;
- cout << "Income Tax: $" << incomeTax << endl;
- cout << "State Income Tax: $" << stateTax << endl;
- cout << "Union Tax: $" << unionTax << endl;
- cout << "Insurance Tax: $" << insuranceTax << endl;
- cout << "-----------------------" << endl << "Net Pay: $" << netPay << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement