A simple calculator for performing basic mathematical operations for grade 4, 5, and 6. This is the plus version of the "Calc Rizz" Calculator.
This project is essentially the same as a the calc-rizz standard version in its core functionalies. The main changes exist in the user interface, as the plus version takes a more 'mature' look. I have also improved the documentation of how each part of the project works. The final change is the fix to the "divide by zero" calculation which is now handled appropriately instead of crashing the program. While this could have been all done on the standard version, I chose to make a new one particulary to preserve the user interfaces of both calculators.
Calc Rizz Plus
A simple calculator for performing basic math operations for grade 4, grade 5 and grade 6
Ver. 1
Anyanwu Benedict Chukwuemeka (https://github.com/ACBennny)
This calculator is a package named CalcRizz. In this package I have split the design of this calculator into 4 sections, all performing a different major function in the calculator's development. These include:
-
CalcRizzMain This is the main class (javafx class) of the Package. It is where the scene and stage are instatiated. Running this class will start the program containing the calculator.
-
CalcRizzControl This is the 'controller' class (java class) of the CalcRizz package. It essentialy contains all necessary methods required for the functionality of the calculator. In this class there exists
- A method which is automatically called for loading files and initializing variables andmethods.
- A method to display to the screen, the operations performed by the user on the calculator
- A method to clear the display of the claculator to allow for more calculations to beperformed
- A method that will essentially perform all operations defined for this calculator
- Media players to play sounds when the app starts and when buttons are pressed
-
CalcRizzStruct This is a FXML document. It is similar to the standard HTML documents used for web development in terms of schema and structure. It primarily serves as the 'skeleton' of the calculator. This means it holds the structure by which the calculator is built upon.
-
CalcRizzStyle This is a cascading stylesheet or populary known as CSS sheet. As the name implies, it's soley made for styling the calculator and giving it the unique design seen once the program has been started.
NB:
- The CalcRizzStyle and CalcRizzStruct files are located in the 'src' folder.
- Images used in the creation of this project are not created or in any manner affiliated with me. All credits got to their respective owners
- This is a blueJ project and thus blueJ is preferred for running this project.
Let's take a look into the function process of this calculator.
-
Gets the text in the input of the label
-
Splits the text into parts. An array called components stores these parts.
-
It checks that it is a valid expression. A valid expression is in the following order
-----> " 10 " , " + " , " 1 " <------
This above expression consists of three parts. A non valid expression causes an error message to be displayed.
-
The 3 parts are defined as follows;
--> part 1 is the first operand and is stored in operand1 (Integer)
--> part 2 is the operator
--> part 3 is the second operand and is stored in operand2 (Integer)
-
A variable called "result" is used to store calculated varaibles (subject to modification)
-
A variable called "pickedRadBtn" radio group for the grade of maths (ie grade 4 , 5 and 6)
-
The id of the selected radio button is stored in "pickedRadBtnId"
-
I ensure that a radio button is always selected (The "grade 4 math" is selected by default)
-
If a radio button is selected, a switch case ensues based on the operator
-
Each operation and conditions (if applicable) are listed below
Works normally for all grades.
Works normally for all grades.
Grade 4
- Subtraction only works if the first operand is greater than/equals to the second operand. i.e. operand1 >= operand2
- If the above condition is not met, an error message is displayed.
Grade 5 and 6
- Subtraction works normally for both grades.
Grade 4
- Division works only if there is no remainder in the operation else an error is displayed.
Grade 5
- We make use of quotient and remainder.
- The quotient and remainder is calculated
- The results are displayed in the format: "quotient" , " R " , "remainder" e.g. 4 R 1
Grade 6
- The use of decimals is employed but all digits must round up to 4 decimal places.
- The operands are converted to double, the operation follows suit.
- The result of the division is formated to 4 decimal places using the DecimalFormat class.
- The formatted result is then displayed.
To start the calculator,
- Open the the project (preferrably using blueJ)
- Right click and run the "CalcRizzMain.java"
- After a few seconds, the app should open ready to use.