Skip to content

Rohan-003-Gusain/Java-Console-Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Java Console Calculator

A simple console-based calculator built in Java. It supports addition, subtraction, multiplication, division.


Features

  • 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)

How to run

  1. Compile the Java file:

    javac JavaConsoleCalculator.java
  2. Run the program:

    java JavaConsoleCalculator
  3. 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
    -----------------------------------------
    

Notes

This project demonstrates Java OOP, methods, loops, conditionals, and Scanner I/O.

Double wrapper class is used to handle divide-by-zero scenario.

About

A simple Java console-based calculator for basic arithmetic operations.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages