// Homework #4 sample solution

#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>

// Throw away salaries above this value.
// By congressional order, this may be a bug.
const float cutoff = 100000.0;

int main()
{
  // Functions used by Main()
  int filter (float);
  float transform (float);

  // variables used by Main()
  float salary;
  ifstream in;
  
  in.open("input");
  if (!in)           
  {
    cerr << "Input file does not exist." << endl;
    return 1;
  }
  
  cout.setf(ios::fixed,ios::floatfield);
  cout.setf(ios::showpoint);

  // for each salary below the cutoff, output the transformed value
  for (in >> salary; in; in >> salary)
    if (filter(salary))
      cout << "$" <<setw(8) <<setprecision(2) << transform(salary) << endl;

  return 0;
}

// salary is a positive number indicating a salary.
// return true if the salary is below the cutoff, false if above.
int filter(float salary)
{
  return salary < cutoff;
}

// salary is a positive number indicating someone's salary
// returns the adjusted income based on a rough estimate of
// taxes paid.
float transform(float salary)
{
  return (salary-2000) * .70;
}

