Exercise 1C.1 Develop the function
taxRate that determines the tax rate for a given income
level. If the income is under $6000, there is no tax. For an
income under $20000 the tax is 15%, for income under $70000 the
tax is 24%, for $70000 and over the tax is 33%.
Develop the function computeTax that will compute the
amount of tax for the given income, using the tax rates as
determined earlier.
Exercise 1C.2 Develop the function ticketType that produces an age label (a String) for a ski ticket, given the age of the skier. The result is "Child" for those under six years old, "Youth" for those under twelve, "Student" for those under 21, "Adult" for those under 65, and "Senior" for anyone 65 and older.
Exercise 1C.3 Develop the function letterGrade that consumes the exam score (between 0 and 100) and produces a character representing the earned grade as follows: 85 and above is A, 70 and above is B, 60 and above is C, 50 and above is D, below 50 is F.
Exercise 1C.4 Develop the function
passing that consumes the exam scores from two exams (a
midterm and a final) and produces a Boolean value that
indicates whether the student passes the course. Student who
either failed both exams, or got F on one exam and D on the
other, fails the course, otherwise student passes the course.
Hint: Use the function letterGrade as a helper.
Exercise 1C.5 Modify the function letterGrade, so that if the reported score is negative, or greater than 100, an exception with the message "Score out of range" is raised.
Exercise 1C.6 Develop the function
computeToll that computes the toll for a vehicle passing
through the toll booth, given information about the vehicle. The
vehicle driver hands in a ticket with one character code as
follows: A is for a passenger car (automobile), B is for bus, T is
for a truck, W is for a car towing a small trailer or a boat or an
airplane (glider in a box). The ticket also has the code that
determines the distance travelled. The toll structure is as
follows. Passenger cars pay $0.25 per 10 miles of travel, rounded
down, car with a trailer pays $0.35 per 10 miles. Bus pays $0.50
per 10 miles and an additional surcharge of $5 if the distance is
greater than
100 miles. Trucks pay $0.40 per 10 miles, with a minimum of $5.
Remember the basic guidelines and develop two auxiliary functions
to deal with bus and truck tolls.
Your purpose statement must specify clearly the range of
acceptable input values for the vehicle code and the distance
travelled.