Skip to content

ISEP-Projects-JH/Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฎ Calculator

๐Ÿงพ Project Summary

This project implements a simple calculator in Java that can parse and evaluate mathematical expressions represented as strings. It supports:

  • Positive and negative numbers
  • Floating-point numbers
  • The four basic operations: +, -, *, /
  • Parentheses with proper precedence
  • Multiple unary signs (--, -+, etc.)

All required unit tests (CalculatorTest.java) are fully passing, including the bonus tests for negative numbers and parentheses.


๐Ÿงช How to Run the Tests

This project uses JDK 17 (LTS).

๐Ÿ”ง Option 1: Maven

mvn clean test

๐Ÿ”ง Option 2: IntelliJ / Eclipse

  • Make sure project SDK is set to JDK 17
  • Open CalculatorTest and Run All Tests

๐Ÿš€ How to Run the Calculator

Compile the project:

javac -d out \
  src/main/java/org/isep/cleancode/Main.java \
  src/main/java/org/isep/cleancode/calculator/Calculator.java

Start the REPL:

java -cp out org.isep.cleancode.Main

Example:

> --1
= 1.0
> (1 + 2) * 3
= 9.0
> exit
Goodbye!

๐Ÿง  Implementation Notes

  • Unary operators are handled using a posi flag to manage sign logic.
  • Parentheses are parsed recursively.
  • The implementation avoids third-party libraries and focuses on clear, readable logic.
  • Only standard Java (java.util) is used.

๐Ÿง‘โ€๐Ÿ’ป Tech Stack

  • Java 17
  • JUnit 5
  • Maven

๐Ÿ† Bonus Achievements

  • โœ… Negative numbers supported
  • โœ… Parentheses supported
  • โœ… Public GitHub repo (if you share the link in your email)

About

๐Ÿง  A handcrafted math expression interpreter in Java โ€” zero dependencies, full control.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages