Check the links in the step by step above for methods

This preview shows page 3 out of 3 pages.

Check the links in the step-by-step above for methods to read lines from the keyboard in Processing. You might find some use for buttons as well, as in this example: Remember to watch for boundary conditions – these are the limiting or extreme cases that your logic might otherwise miss – for example: price and amount paid exactly equal, either price or amount paid greater than 50, or less than 0, and so on. Catch these with if statements, issue an informative error message and stop processing or try to recover if you like. [And here's a BIG hint – you can avoid a lot of possible pitfalls if you work everything out in pennies (i.e. $5.67 = 567 cents) and use integer math instead of floating point.] Scoring Please submit your source code and sample output for several values of price and amount paid. Extra Credit Add code to allow your program to deal with needing to make change when your till is out of a particular denomination. In other words, I buy something for $5.13 with a $20, but I have no $10's in the till. (So I would use two $5's). And so forth. It might be overkill for this problem, but you could handle this by throwing an OutOfDenomination ( int faceValue ) exception in some makeChange method, and then catching it and retrying with the next lower value, and so forth. Just a thought. A good job on this part could double the points this exercise is worth, because I think you'll get a concrete example of the programmer's adage -- “Error handling is half the work”.
Image of page 3
You've reached the end of this preview.
  • Spring '08
  • GeraldReed
  • $5, Meyer, $5.13

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern