Java Reference
In-Depth Information
decimal;
hexadecimal.
The calculator must be able to read numbers entered in any combination
of base and representation format, and convert them into any other possible
base and
or format.
Operands and operators are entered according to the postfix notation:
first the operands, then the operation. For instance, to sum the values 1 and
2 the following steps are required:
1 enter first operand:
1
2 enter second operand:
2
3 specify operation:
!
4 result:
3
For the sake of simplicity, the calculator is able to perform only the four
basic arithmetic operations. The program must provide a simple and intuitive
interface that allows experimenting with different formats and basis.
6.2
Problem analysis
The most important feature of the calculator is the capability to handle
different number bases and formats. Table 6.1 summarizes all the possible
combinations of bases and formats.
The program can be used according to different modalities as described in
the use case presented in Figure 6.1. First of all the calculator is a tool used
to perform calculations; in this mode the user provides the operands, the
operations to be performed and receives the results. In addition it must be
possible to change the representation format and the number base; when the
user selects a new format and
or base the calculator visualizes the values
accordingly. These two modalities interact closely. The result of the calcu-
lation is provided using the most recently selected pair of representation
format and number base.
When either the representation format or the number base is changed
the calculator should visualize the result of the most recent calculation
accordingly.
6.2.1
Domain models
The two main issues, i.e. the number bases and the representation formats,
Table 6.1 Instruction set
Binary
Decimal
Hexadecimal
Fixed point
0.11
0.75
0.C
1.1 + 10 01
7.5 + 10 01
C.0 + 10 01
Floating point
Fractional
11 100
3 4
3 4
 
Search WWH ::




Custom Search