This is a simple logical calculator implemented in Java using Swing for the GUI.
- Basic arithmetic operations: addition, subtraction, multiplication, division, and modulus.
- Logical operations: AND, OR, XOR, NOT, NAND, NOR.
- Radix conversion: Decimal, Binary, Hexadecimal.
- Input and output in the specified radix.
The calculator is implemented as a Swing GUI application with the following key components:
- Main Class:
Calculator
- GUI Components:
JTextField
for displaying the current input/result.JLabel
for displaying the expression.JButtons
for numeric input, arithmetic/logical operations, and other functionalities.JRadioButtons
for selecting the radix (Decimal, Binary, Hexadecimal).JPanel
for organizing buttons in a grid layout.
- Run the application.
- Input numeric values and perform arithmetic or logical operations.
- Select the desired radix for input and output.
-
Numeric Input:
- Use numeric buttons (
0-9
) and alphabetic buttons (A-F
in hexadecimal mode). - Decimal point (
.
) is available for floating-point numbers.
- Use numeric buttons (
-
Arithmetic Operations:
- Addition (
+
), Subtraction (-
), Multiplication (*
), Division (/
), Modulus (%
). - Change sign (
+/-
).
- Addition (
-
Logical Operations:
- AND (
AND
), OR (OR
), XOR (XOR
), NOT (NOT
), NAND (NAND
), NOR (NOR
).
- AND (
-
Other Functions:
- Clear Entry (
CE
): Clears the current input. - Delete (
DEL
): Removes the last character from the input. - Equals (
=
): Calculates and displays the result.
- Clear Entry (
-
Radix Selection:
- Use radio buttons to switch between Decimal, Binary, and Hexadecimal input and output.
Decimal Input: Binary Output:
1 + 1 = 2 1 + 1 = 10
3 AND 1 = 1 11 AND 01 = 01
- Java Swing