All pastes #736890 Raw Edit

Ahmed medhat

public text v1 · immutable
·published 2007-10-14 22:19 UTC
rendered paste body
#include <iostream>

using namespace std;

int
main ()
{
  // read number of work hours
  double num_of_hours_worked;
  cout << "\n";
  cout << "insert number of hours worked in a week: ";
  cin >> num_of_hours_worked;

  // read dependents
  int num_of_dependents;
  cout << "insert number of dependents: ";
  cin >> num_of_dependents;

  // payment for work hours (declared as double to get exact decimal value of values multiplied by it)
  double orig_payment_per_hour = 16;

  // payment for overtime work hours
  double overtime_payment_per_hour = 1.5 * orig_payment_per_hour;


  double total_payment_un_manipulated;
  cout << "\n";


  // check if there's overtime worked hours or not to give the suitable output
  if (num_of_hours_worked < 40)
    {
      cout << "payment for original work hours in a week: $" <<
        (num_of_hours_worked * orig_payment_per_hour) << endl;

      total_payment_un_manipulated =
        (num_of_hours_worked * orig_payment_per_hour);
    }
  else if (num_of_hours_worked > 40)
    {
      double overtime_hours;
      overtime_hours = (num_of_hours_worked - 40);
      cout << "payment for original work hours in a week: $" << (40 *
                                                            orig_payment_per_hour)
        << endl;
      cout << "payment for overtime work hours in a week: $" <<
        (overtime_hours * overtime_payment_per_hour) << endl;

      total_payment_un_manipulated =
        (40 * orig_payment_per_hour) +
        (overtime_hours * overtime_payment_per_hour);
    }


  cout << "total worker's gross payment is: $" << total_payment_un_manipulated
    << endl;

  double net_take_home;
  net_take_home =
    (((total_payment_un_manipulated) -
      (total_payment_un_manipulated * 6 / 100)) - 10);

  if (num_of_dependents >= 3)
    {
      net_take_home = (net_take_home - 35);
      cout <<
        "total net-take-home after removing %6 for social security taxes and $10 for union dues per week and $35 for dependents: $"
        << net_take_home << endl;
    }
  else if (num_of_dependents < 3)
    {
      cout <<
        "total net-take-home after removing %6 for social security taxes and $10 for union dues per week: $"
        << net_take_home << endl;
    }

  cout << "\n";
  return 0;
}