Skip to content

Add ReturnOnInvestment to maths#7446

Open
InukaWijerathna wants to merge 3 commits into
TheAlgorithms:masterfrom
InukaWijerathna:add/return-on-investment
Open

Add ReturnOnInvestment to maths#7446
InukaWijerathna wants to merge 3 commits into
TheAlgorithms:masterfrom
InukaWijerathna:add/return-on-investment

Conversation

@InukaWijerathna
Copy link
Copy Markdown

Description

Adds ReturnOnInvestment to the maths package.

Return on Investment (ROI) is a fundamental financial metric that quantifies how profitable an investment is relative to its cost:

ROI = (Gain from Investment - Cost of Investment) / Cost of Investment × 100

What's included

  • ReturnOnInvestment.java — clean implementation with Javadoc and IllegalArgumentException for invalid cost
  • ReturnOnInvestmentTest.java — 6 JUnit 5 tests covering positive, zero, and negative ROI, plus error paths

Checklist

  • Follows the code style of the project (final class, private constructor, static method)
  • JUnit 5 tests for all branches including exception cases
  • Javadoc with formula and reference link

Reference: https://www.investopedia.com/terms/r/returnoninvestment.asp

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.73%. Comparing base (cecfad9) to head (ff3feff).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7446   +/-   ##
=========================================
  Coverage     79.72%   79.73%           
- Complexity     7298     7300    +2     
=========================================
  Files           803      804    +1     
  Lines         23762    23765    +3     
  Branches       4674     4674           
=========================================
+ Hits          18945    18948    +3     
  Misses         4059     4059           
  Partials        758      758           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants