|
|
HTW Berlin
Fachbereich 4
Internationaler Bachelor Studiengang
Internationale Medieninformatik (Bachelor)
Info 2: Informatik II
Summer Term 2023
|
Exercise
8: Fun with Calculators 2
|
Finger
Exercises
Please think through the following questions
before coming to the lab. Write down your answers and bring them with you
for check-in.
- Make sure that your infixToPostfix
and evaluatePostfix methods from exercise 6 are in working
order! If not, ask to use one from another group. Re-use is good, if you
give proper credit in your report.
Lab
exercises:
- Make a copy of one of your
Calculators. Make sure that it works before you
begin! If neither of you got a Calculator to work, ask
colleagues for permission to use theirs. Give them credit in your
report!
- 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.
- 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!
- What will be good test cases for the precedence
of * over +? Find 15 good test cases and try them out, documenting the
results.
- Check that this still works with hexadecimal
numbers.
For
the bored:
- Now include the exponentiation operator ^ (2^4
= 16). It has a higher priority than either multiplication or division.
- Extend your integer calculator to do
multi-digit and doubles.
- Extend your calculator to calculate the
factorial (!). What do you have to change in your algorithm?
- Make your calculator usable for blind people -
have your calculator read aloud the button pressed.
- How can you make the calculator read the result
for blind users in German? In English?
Your report is due by 10.00
pm the evening before your next lab! As in Informatics 1, we
are more interested in process than in product, although we are now
getting more interested in products as well. Your report should include
any collaborators, summarize what you learned, and note the time you
invested in this exercise. How many lines of code did you write for each
exercise? Record this in your report.
Copyright
Prof. Dr. Debora Weber-Wulff
Questions or comments:
<weberwu@htw-berlin.de>
Some rights reserved. CC-BY-NC-SA - Copyright and Warranty