HTW Berlin Medieninformatik

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


Exercise 5: Fun with Calculators - Week 1

Finger exercises
  1. We played around with a calculator last semester. Here's the code: calculator-full-solution. Have a look at how it solves the problem of reading in a digit followed by an operator followed by a digit, and how you figured out how to calculate the value when = was pressed.
  2. Is there anything impoutant missing in this calculator? Beware: do not expect to read and understand this in the first few minutes of the lab! Read it at home, discuss it with others! How does it work?
  3. What are hexadecimal numbers?

Lab exercises

  1. Implement the missing functionality for single digit numbers and only one operator discovered in the pre-lab.
  2. Extend your integer calculator to include buttons for entering in the hexadecimal digits. Make the calculator do its calculations and display in hexadecimal notation.
  3. Integrate a checkbox for switching between decimal and hexadecimal formats. Do not show the hexadecimal digits (or grey them out) when you have the calculator in decimal mode.
  4. What test cases do you need to test your calculator?

For the bored:

  1. Make a whole collection of calculators: binary, octal, decimal, hexadecimal. Maybe make a CalculatorFactory that takes the base as a parameter to the constructor, figures out how to layout the buttons nicely, and calculates in the selected base mode?
Work in groups of two, each of you submitting the same report, detailing who did what part of the work. Your reports are due by 23.00 next week‚.


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