A feature-rich scientific calculator built with Java and JavaFX, featuring a modern dark theme and comprehensive mathematical operations.
- Addition, Subtraction, Multiplication, Division
- Decimal point support
- Sign change (+/-)
- Power operations (x^y)
- Trigonometric: sin, cos, tan, asin, acos, atan
- Logarithmic: Natural logarithm (ln), Common logarithm (log)
- Exponential: e^x
- Other: Square root (√), Square (x²), Reciprocal (1/x), Factorial (x!)
- π (Pi): 3.14159...
- e (Euler's number): 2.71828...
- Angle Mode Toggle: Switch between Radians and Degrees
- Clear Functions:
- C (Clear all)
- CE (Clear entry)
- Backspace
- Error Handling: Graceful handling of division by zero and invalid operations
- Minimalistic UI: Dark theme with color-coded buttons for easy navigation
- Java Development Kit (JDK): Version 17 or higher
- JavaFX SDK: Version 17 or higher (must match your Java version)
| Java Version | Compatible JavaFX Version |
|---|---|
| Java 11-17 | JavaFX 17 |
| Java 18-20 | JavaFX 20 |
| Java 21+ | JavaFX 21+ |
-
Install Java JDK
- Download from: Oracle JDK or OpenJDK
- Verify installation:
java -version
-
Download JavaFX SDK
- Download from: Gluon JavaFX
- Extract to a location (e.g.,
C:\javafx-sdk-17)
Clone or download this repository:
git clone https://github.com/yourusername/scientific-calculator.git
cd scientific-calculatorRefer to your IDE or build tool documentation for running JavaFX applications with the appropriate module path configuration.
scientific-calculator/
├── README.md
└── ScientificCalculator.java # Main application file
- Enter numbers using the number pad (0-9)
- Click an operator (+, -, *, /)
- Enter the second number
- Press = to see the result
- Enter a number
- Click the desired function (sin, cos, log, etc.)
- The result is displayed immediately
- Click π to insert Pi value
- Click e to insert Euler's number
- Click Rad to toggle between Radians and Degrees mode
- Affects trigonometric functions (sin, cos, tan)
- x^y: Enter base number, click x^y, enter exponent, press =
- x!: Enter a non-negative integer, click x!
- +/-: Change the sign of the current number
- 1/x: Calculate reciprocal of current number
| Button | Function |
|---|---|
| 0-9 | Number input |
| . | Decimal point |
| +, -, *, / | Basic arithmetic operators |
| = | Calculate result |
| C | Clear all (reset calculator) |
| CE | Clear current entry |
| < | Backspace (delete last digit) |
| sin, cos, tan | Trigonometric functions |
| asin, acos, atan | Inverse trigonometric functions |
| ln | Natural logarithm |
| log | Common logarithm (base 10) |
| sqrt | Square root |
| x^2 | Square |
| x^y | Power |
| 1/x | Reciprocal |
| x! | Factorial |
| exp | Exponential (e^x) |
| π | Pi constant |
| e | Euler's number |
| +/- | Change sign |
| Rad/Deg | Toggle angle mode |
- Cause: JavaFX is not installed or not in the module path
- Solution: Download JavaFX SDK and specify the correct path with
--module-path
- Cause: JavaFX version doesn't match your Java version
- Solution: Download compatible JavaFX version (see compatibility table above)
- Cause: Java is not installed or not in PATH
- Solution: Install JDK and add to system PATH
- Cause: JavaFX runtime modules not loaded
- Solution: Ensure
--add-modules javafx.controlsis specified when running
- Cause: Invalid input or operation
- Solution: Click C to clear and try again
Compile the source code:
javac --module-path /path/to/javafx-sdk/lib --add-modules javafx.controls ScientificCalculator.javaRun the application:
java --module-path /path/to/javafx-sdk/lib --add-modules javafx.controls ScientificCalculatorWindows Example:
javac --module-path "C:\javafx-sdk-17\lib" --add-modules javafx.controls ScientificCalculator.java
java --module-path "C:\javafx-sdk-17\lib" --add-modules javafx.controls ScientificCalculatorLinux/Mac Example:
javac --module-path /opt/javafx-sdk-17/lib --add-modules javafx.controls ScientificCalculator.java
java --module-path /opt/javafx-sdk-17/lib --add-modules javafx.controls ScientificCalculator- Open project in IntelliJ
- File → Project Structure → Libraries
- Add JavaFX SDK library
- Run → Edit Configurations
- Add VM options:
--module-path /path/to/javafx-sdk/lib --add-modules javafx.controls
- Open project in Eclipse
- Right-click project → Properties → Java Build Path
- Add External JARs from JavaFX SDK lib folder
- Run → Run Configurations
- Add VM arguments:
--module-path /path/to/javafx-sdk/lib --add-modules javafx.controls
- Install Java Extension Pack
- Create
.vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "ScientificCalculator",
"request": "launch",
"mainClass": "ScientificCalculator",
"vmArgs": "--module-path /path/to/javafx-sdk/lib --add-modules javafx.controls"
}
]
}Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Memory functions (M+, M-, MR, MC)
- Scientific notation input
- Parentheses support for complex expressions
- History of calculations
- Keyboard input support
- Theme customization
- Export/save results
- Unit conversions
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name - Sahil Sharma
Project Link: https://github.com/Developer-Sahil/scientific-calculator
- Built with JavaFX
- Inspired by modern calculator designs
- Special thanks to the Java community
Note: This calculator is designed for educational purposes and basic scientific calculations. For advanced mathematical operations, consider using specialized software like MATLAB, Mathematica, or SciPy.
