Skip to content

A simple command-line calculator built with Java.

Akryptix/java_simple_calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

💻 Simple Calculator

A robust command-line calculator built with Java. This project demonstrates fundamental object-oriented programming (OOP) principles and robust error handling to create a simple, yet reliable, calculator that can perform basic arithmetic operations.

✨ Features Four Basic Operations: Supports addition +, subtraction -, multiplication *, and division /.

User-Friendly Interface: The program runs continuously, allowing for multiple calculations without restarting.

Intelligent Input Handling: Prevents crashes by validating user input and catching non-numeric values.

Robust Error Management: Handles common errors like invalid operation symbols and division by zero with clear, concise messages.

🚀 How to Run Save the file: Ensure your single file is named simplecalculator.java.

Compile the code: Open your terminal or command prompt and compile the file. You only need to specify the one file name.

Bash

javac simplecalculator.java Run the program: After successful compilation, run the main class.

Bash

java simplecalculator

🧠 Concepts Learned This project was a fantastic opportunity to apply core computer science concepts in a practical way. Key areas of learning include:

Object-Oriented Programming (OOP): I designed the program using a separate class (op) to handle the operational logic, demonstrating the principles of encapsulation and modular design.

Input Validation: I implemented a try-catch block with a while loop to ensure the program only accepts valid numerical input, a crucial skill for building reliable applications.

Exception Handling: I used try-catch blocks to gracefully manage runtime errors like InputMismatchException and ArithmeticException, providing a better user experience.

Control Flow: The program's structure relies on while loops and if/else statements to control the flow and repeat operations until the user decides to exit.

Feel free to connect with me! I'm always open to feedback and collaboration on future projects.

About

A simple command-line calculator built with Java.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages