Skip to content

himanshumanik/Java-Console-Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Java Console Calculator 🧮

This repository contains the solution for Task 1: Java Console Calculator.

Objective

The goal of this task was to create a basic command-line calculator program in Java that allows users to perform standard arithmetic operations and includes a loop for multiple calculations until the user chooses to exit.

Features Implemented

  • Console I/O: Uses the java.util.Scanner class to accept user input for numbers and the operator.
  • Arithmetic Operations: Supports addition (+), subtraction (-), multiplication (*), and division (/).
  • Continuous Loop: The program runs within a while loop, allowing for multiple consecutive calculations.
  • Exit Command: Users can type exit when prompted for the first number to gracefully close the application.
  • Error Handling:
    • Checks for and handles division by zero.
    • Uses a try-catch block to handle invalid input (e.g., non-numeric characters) and prompts the user to re-enter data.

How to Run

  1. Clone the repository:
    git clone [Your Repo URL Here]
  2. Compile the Java file:
    javac Calculator.java
  3. Run the compiled class:
    java Calculator

Example Usage

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages