HTW Berlin Medieninformatik

HTW Berlin
Fachbereich 4
Internationaler Studiengang
Internationale Medieninformatik (Bachelor)
Info 2: Informatik II
Winter Term 2010/11


Exercise 7: Fun with Calculators - Week 2

Finger exercises
  1. Make sure that your infix-to-postfix and evaluate-postfix methods are in working order! If not, ask to use one from a friend. Re-use is good, if you give proper credit in your report.

Lab exercises

  1. Make a copy of your Calculator. Make sure that it works before you begin!
  2. Rework it to accept a long String of single digits separated by operators that have precedence. The bored may use multi-digit numbers and floating-point or scientific notation, if they please.
  3. Once you get a String input, add in calls to convert this expression to postfix and evaluate the postfix when = is pressed. Presto, your calculator now takes care of operator priorities, like magic! Just a little bit of mathematical thought, and you can introduce new functionality!
  4. What will be good test cases for the precedence of * over +? Find 15 good test cases and try them out, documenting the results.
  5. Check that this still works with hexadecimal numbers.
  6. Now include the exponentiation operator ^ (2^4 = 16). It has a higher priority than either multiplication or division.

For the bored:

  1. Extend your integer calculator to do multidigit and doubles.
  2. Extend your calculator to calculate the factorial (!). What do you have to change in your algorithm?
  3. Make your calculator usable for blind people - have your calculator read aloud the button pressed.
  4. How can you make the calculator read the result for blind users in German? In English?
Work in groups of two, each of you submits the same report, detailing who did what part of the work. Your reports are due by 23.00 next Wednesday.


Copyright 2010 Prof. Dr. Debora Weber-Wulff
Questions or comments: <weberwu@htw-berlin.de>
Some rights reserved. - Copyright and Warranty