Skip to content

Advanced calculator | Java Programming Language - FIT Brno University of Technology

License

Notifications You must be signed in to change notification settings

gmm96/IJAe_BUT_Brno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IJAe 2017/18 Project

December, 2017

Assignment

Creating a calculator application that provides both basic and more complex mathematical operations and supports number representation in different bases (decimal, binary, etc.). For this task, I use a well-known JavaScript library called math.js as calculation engine. Math.js features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.

Graphical user interface specification

  1. Input and Output fields– the application provides the option to input the numeric values from keyboard. It also displays a list of the expressions along with their results. One click in one expression will write in input field.
  2. C, CE and DEL buttons– allow to delete the current input, erase the memory and delete the last digit/operator from the user input respectively.
  3. Equals sign button– starts the computation.
  4. Number buttons, parethesis buttons, decimal mark button– allow to input numeric values without using keyboard, include hexadecimal values as well. Keyboard could also be used.
  5. Basic maths operation buttons– include addition, multiplication, subtraction, division and modulo operations.
  6. Numeric base option– allows the user to choose in which numeric base the numbers are represented. Number buttons are enabled / disabled accordingly to the current base selected (e.g. with binary numbers, only 1 and 2 are enabled). Input values also changes when calculation base is changed.
  7. Advanced maths operation buttons– include sinus, cosinus, exponential function, logarithm with the base of 2 and natural logarithm. User can choose whether the advanced operations are displayed or hidden.
  8. Edit menu with options to copy from both fields and paste to the input field.
  9. Help section with credits about the application and an manual of use. This will show the documentation for the math.js library for advance input use.

Functionality specification

  • The calculator has memory storing the result of the last computation.
  • The next computation can use the value in memory as its first operand.
  • The application provides different modes of use depends on the level of the user: a noob mode with basic use; a guided mode with restricted input; and an advance mode with free input, which will help us to take real advantage of calculation engine math.js
  • User is able to provide input expressions from the keyboard. The application checks the format and ensure the correctness of the user input. A warning should be shown in case of incorrect input.
  • Angles can be expressed in degrees or radians.
  • Main class is called CalcDemo.java. Math.js is obtained by internet.

Project can be compiled and executed by the next commands in root project folder:

    $ ant
    $ java -jar dist/xmonte03.jar

Captures

Binary base

Octal base

Decimal base

Hexadecimal base

Calculation example