Calculator Android Application

Author

Aditya Bansal

Features

The application provides basic calculation functionality – addition, subtraction, multiplication, division, modulus, power, square root, factorial, sin(in Radians), cos(in Radians) and tan(in Radians) in addition to providing buttons for numbers, decimal point, ‘Clear’, and backspace. It uses string, colour, dimension and style resources. The base layout used in Constraint layout with components like LinearLayout, TextViews, Buttons, and ImageButton. There are two layouts – one for portrait mode and one for landscape mode. A separate java class is used for the calculation implementation. SavedInstanceState is used to make sure that the data doesn’t clear if the screen is rotated. There is no keyboard input – it is done using the buttons provided on the screen. The following possible errors are considered, and appropriate action is taken –

  • Making sure that there is only one decimal point in a number
  • The length of the number of characters does not exceed by 10
  • The root button works even if there is no first number provided
  • Possible division errors

When the backspace button is long pressed, all the contents are cleared. Methods are created and reused to reduce code duplication. Compatibility classes are used to provide backwards compatibility for older android versions.

App Logo

This icon represents the application. Made using Font Awesome Icons and MDBootstrap. It follows material design guidelines.

Android Specifications

  • Android Studio Version: 2021.2.1
  • Gradle Version: 6.5
  • Minimum Android SDK: 19
  • Target Android SDK: 33

Screenshots

  • In Portrait Mode-

Main UI

  • In Landsacpe Mode-

Main UI

  • Calculation Example in Portrait Mode-

Calculation being performed 1 Calculation being performed 2

  • Calculation Example in Landsacpe Mode-

Calculation being performed

Usage

The usage of the application is self-explanatory. However, the following steps can be followed –

  1. Enter a number (up to 10 digits) using the number pad provided
  2. Enter an operation using the number pad
  3. Enter the second number (up to 10 digits)
  4. Press the ‘=’ button to perform the calculation
  5. Use the backspace button to delete the last character
  6. Enter the first number before entering an binary operation.
  7. Use ‘C’ button to clear all the fields.
  8. Numbers entered before unary operations are multiplied with the operation.