Giter VIP home page Giter VIP logo

splitwise-lld's Introduction

Splitwise-LLD

An expense sharing application is where you can add your expenses and split it among different people. The app keeps balances between people as in who owes how much to whom.

Requirements Implemented

  1. User: Each user should have a userId, name, email, mobile number.
  2. Expense: Could either be EQUAL, EXACT or PERCENT
  3. Users can add any amount, select any type of expense and split with any of the available users.
  4. The percent and amount provided could have decimals upto two decimal places.
  5. In case of percent, you need to verify if the total sum of percentage shares is 100 or not.
  6. In case of exact, you need to verify if the total sum of shares is equal to the total amount or not.
  7. The application should have a capability to show expenses for a single user as well as balances for everyone.
  8. When asked to show balances, the application should show balances of a user with all the users where there is a non-zero balance.
  9. The amount should be rounded off to two decimal places. Say if User1 paid 100 and amount is split equally among 3 people. Assign 33.34 to first person and 33.33 to others.

Input

  • You can create a few users in your main method. No need to take it as input.
  • There will be 3 types of input:
  • Expense in the format: EXPENSE <EQUAL/EXACT/PERCENT>
  • Show balances for all: SHOW
  • Show balances for a single user: SHOW

Output

  • When asked to show balance for a single user. Show all the balances that user is part of:
  • Format: owes :
  • If there are no balances for the input, print No balances
  • In cases where the user for which balance was asked for, owes money, they’ll be x. They’ll be y otherwise.

Sample Input

SHOW
SHOW u1
EXPENSE u1 1000 4 u1 u2 u3 u4 EQUAL
SHOW u4
SHOW u1
EXPENSE u1 1250 2 u2 u3 EXACT 370 880
SHOW
EXPENSE u4 1200 4 u1 u2 u3 u4 PERCENT 40 20 20 20
SHOW u1
SHOW

Sample Output

No balances
No balances
User4 owes User1: 250
User2 owes User1: 250
User3 owes User1: 250
User4 owes User1: 250
User2 owes User1: 620
User3 owes User1: 1130
User4 owes User1: 250
User1 owes User4: 230
User2 owes User1: 620
User3 owes User1: 1130
User1 owes User4: 230
User2 owes User1: 620
User2 owes User4: 240
User3 owes User1: 1130
User3 owes User4: 240

splitwise-lld's People

Contributors

shivam-25 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.