A simple console-based calculator built in Java. It supports addition, subtraction, multiplication, division.
- Perform basic arithmetic operations: Add, Subtract, Multiply, Divide
- Handles division by zero gracefully
- Smart result display:
- Prints integer result if no decimal
- Prints decimal result if needed
- Input validation for menu selection (1–5)
-
Compile the Java file:
javac JavaConsoleCalculator.java
-
Run the program:
java JavaConsoleCalculator
-
Follow the menu to perform calculation:
<--- Welcome to Java Console Calculator ---> Select the operation you want to perform: 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exit Enter Your Choice----: 1 Enter first number: 10 Enter second number: 5 Result: 15 -----------------------------------------
This project demonstrates Java OOP, methods, loops, conditionals, and Scanner I/O.
Double wrapper class is used to handle divide-by-zero scenario.