Confidential Teaching Materials:
Quiz 7 Grading Criteria
Note: To receive any credit whatsoever, the date, your name, your student number, and your answers must
be legible and readily readable in the judgment of the grader.
Add brief explanatory comments as necessary to make sure your answers are clear and unambiguous
to the grader.
You are hired to work for a phone company during the summer. They have asked you to write part of a class,
Phone_Card, that will keep track of a pre-paid calling card. Of the various modules required, you are
responsible for the following ones:
Make_Call: this module will take in the amount of time (in minutes) for a given call. Each call will cost $0.15 per
minute. Make_Call deducts the cost of the call from the card’s current value. For purposes of this quiz, you
are to assume that, when making a call, the user is prompted by the system to specify the length of call to me
made, verifying that there is enough value left on the calling card to pay for that call, and that the call lasts
exactly that predetermined length of time. Thus, a given call may exhaust the balance but will never achieve
a negative balance. The initial value of a Phone_Card is $25.
Buy_Time: this module will take in the amount of money the person has purchased and add it to his/her card.
Each minute purchased costs $0.15. The purchase value should be added to the card’s value.
Balance: this module will return the current amount of time left on the card
[p1] 30 points
Write the public section for the class described above. You must include necessary comments, including purpose,
pre- and post-conditions.
LINES=30
[c1] 30 points
Example solution (particulars may vary):
class Phone_Card
public
function Balance isoftype Num ()