You are an intern working for Congress. The members of the House finances committee are quite worried that the American people will not be pleased to see how high the salaries have gotten for public servants. They have decided that, rather than publishing the unadjusted gross incomes of members of congress, instead they will published the adjusted net income, after taxes. After all, members of congress spend a lot of their income on legitimate tax-deductable items.
In a meeting behind closed doors, the committee members charge you with taking the raw output from the congressional payroll computers (which are simply numbers indicating all the salaries being paid) and transforming these numbers into the adjusted net income. Just after the meeting ends, however, the committee chair pulls you aside and indicates how disappointing it would be if a bug in the program prevented salaries in excess of $100,000 from "making it through."
As you are about to object to the moral and ethical implications of this statement, the committee chairperson hands you a picture of your family, taken through the window of the house at the last holiday dinner. "I hear that Y2K bug can cause a lot of damage. We wouldn't want anyone to get hurt."
You know what you must do.
Write a program that will do roughly what our old pals "map" and "keep" do in Scheme: it will remove some elements of a file, and transform the rest according to some function. Your project should consist of three parts:
filter, that takes one
floating-point number, a salary, and returns true if the salary is
less than $100,000, and false if it is greater.
transform, that takes a single
floating point argument, a salary, and returns the "adjusted net
income" for that salary. The adjusted net income is computed
as:main, which will read in the elements of
a file called "input", and for each element in the file,
if the element passes the filter (is a number less than 100,00), the
result of calling the transformation function will be output to the
screen. If the element does not pass the filter then it is ignored. The
output should be formatted so that all numbers appear on a line with a dollar
sign and two decimal places, and the decimal points should line up.
Your program should report an error and terminate if there is a problem opening the file "input".
For example, if the contents of the file "input" are:
99500 67874.98 87656.01 103454.98 15076.45 200039 39384.60
Then the output of your program should be:
$68250.00 $46112.49 $59959.21 $ 9153.52 $26169.22
You will submit your assignment to congress via the submit102 program.
Grading criteria: