diff --git a/.project b/.project
new file mode 100644
index 0000000..fb5ecfd
--- /dev/null
+++ b/.project
@@ -0,0 +1,11 @@
+
+
+ mock-machine-coding-2
+
+
+
+
+
+
+
+
diff --git a/SplitWise/src/com/workattech/sw/driver/DriverClass.java b/SplitWise/src/com/workattech/sw/driver/DriverClass.java
new file mode 100644
index 0000000..5502d6f
--- /dev/null
+++ b/SplitWise/src/com/workattech/sw/driver/DriverClass.java
@@ -0,0 +1,91 @@
+package com.workattech.sw.driver;
+
+import java.util.ArrayList;
+import java.util.Scanner;
+
+import com.workattech.sw.models.User;
+import com.workattech.sw.service.PrintService;
+import com.workattech.sw.service.SplitWiseService;
+
+public class DriverClass {
+ public static void main(String[] args)
+ {
+ Scanner sc=new Scanner(System.in);
+ User u1=new User("u1","u1.gmail.com","3879872789");
+ User u2=new User("u2","u2.gmail.com","3877872789");
+ User u3=new User("u3","u3.gmail.com","3879872889");
+ User u4=new User("u4","u4.gmail.com","3877872989");
+
+ PrintService printService=new PrintService();
+ SplitWiseService splitWiseService=new SplitWiseService();
+ while(true)
+ {
+ String input=sc.nextLine();
+ String[] inputarray=input.split("\\s+");
+ System.out.println("length "+inputarray.length);
+ if(inputarray[0].equals("SHOW"))
+ {
+ if(inputarray.length==1)
+ {
+ printService.printMoneyOwnedByAll();
+ }
+ else
+ {
+ printService.printMoneyOwnedByParticularUser(inputarray[1],splitWiseService);
+ }
+ }
+ else if(inputarray[0].equals("EXPENSE"))
+ {
+ System.out.println("inside expense");
+ String lender=inputarray[1];
+ int amount=Integer.parseInt(inputarray[2]);
+ int noOfborrowers=Integer.parseInt(inputarray[3]);
+ ArrayList borrowerList=new ArrayList();
+ int i=4;
+ int k=0;
+ while(k percentList=new ArrayList<>();
+ int m=i+2;
+ while(m exactList=new ArrayList<>();
+ int m=i+1;
+ while(m<=i+noOfborrowers)
+ {
+ exactList.add(Integer.parseInt(inputarray[m]));
+ m++;
+ }
+ splitWiseService.distributeMoneyIfExact(borrowerList, lender, exactList);
+ }
+ }
+ }
+
+
+ }
+
+}
diff --git a/SplitWise/src/com/workattech/sw/models/Expense.java b/SplitWise/src/com/workattech/sw/models/Expense.java
new file mode 100644
index 0000000..16899d3
--- /dev/null
+++ b/SplitWise/src/com/workattech/sw/models/Expense.java
@@ -0,0 +1,14 @@
+package com.workattech.sw.models;
+
+public class Expense {
+ private String expenseType;
+ public Expense(String expenseType)
+ {
+ this.expenseType=expenseType;
+ }
+ public String getExpenseType()
+ {
+ return this.expenseType;
+ }
+
+}
diff --git a/SplitWise/src/com/workattech/sw/models/Money.java b/SplitWise/src/com/workattech/sw/models/Money.java
new file mode 100644
index 0000000..4637706
--- /dev/null
+++ b/SplitWise/src/com/workattech/sw/models/Money.java
@@ -0,0 +1,38 @@
+package com.workattech.sw.models;
+
+public class Money {
+ String personA;
+ String personB;
+ double amount;
+ public Money(String moneyGivenBy,String moneyTakenBy,double amount)
+ {
+ this.personA=moneyGivenBy;
+ this.personB=moneyTakenBy;
+ this.amount=amount;
+ }
+ public String getPersonA()
+ {
+ return this.personA;
+ }
+ public String getPersonB()
+ {
+ return this.personB;
+ }
+ public double getAmount()
+ {
+ return this.amount;
+ }
+ public void addAmountGivenByPersonAToPersonB(double amountGivenByPersonA)
+ {
+ this.amount+=amountGivenByPersonA;
+ }
+ public void substractAmountTakenByPersonAFromPersonB(double amountTakenBypersonA)
+ {
+ this.amount-=amountTakenBypersonA;
+ if(this.amount<0)
+ {
+ this.amount=0; //No money is owned by personA from personB
+ }
+ }
+
+}
diff --git a/SplitWise/src/com/workattech/sw/models/User.java b/SplitWise/src/com/workattech/sw/models/User.java
new file mode 100644
index 0000000..4e3e153
--- /dev/null
+++ b/SplitWise/src/com/workattech/sw/models/User.java
@@ -0,0 +1,37 @@
+package com.workattech.sw.models;
+
+import java.util.UUID;
+
+public class User {
+ private String userId;
+ private String userName;
+ private String email;
+ private String mobileNumber;
+ public User(String userName,String email,String mobileNumber)
+ {
+ this.userId=UUID.randomUUID().toString();
+ this.userName=userName;
+ this.email=email;
+ this.mobileNumber=mobileNumber;
+
+ }
+ public String getUserName()
+ {
+ return this.userName;
+ }
+ public String getUserId()
+ {
+ return this.userId;
+ }
+ public String getEmail()
+ {
+ return this.email;
+ }
+ public String getMobileNumber()
+ {
+ return this.mobileNumber;
+ }
+
+
+
+}
diff --git a/SplitWise/src/com/workattech/sw/service/CalculateExpense.java b/SplitWise/src/com/workattech/sw/service/CalculateExpense.java
new file mode 100644
index 0000000..14d84a6
--- /dev/null
+++ b/SplitWise/src/com/workattech/sw/service/CalculateExpense.java
@@ -0,0 +1,14 @@
+package com.workattech.sw.service;
+
+public class CalculateExpense {
+ public double CalculateMoneyEqual(int amount,int number)
+ {
+ return amount/number;
+ }
+ public double CalculateMoneyPercent(int amount,int percent)
+ {
+ double share=percent/100.0;
+ return amount*share;
+ }
+
+}
diff --git a/SplitWise/src/com/workattech/sw/service/PrintService.java b/SplitWise/src/com/workattech/sw/service/PrintService.java
new file mode 100644
index 0000000..94ce723
--- /dev/null
+++ b/SplitWise/src/com/workattech/sw/service/PrintService.java
@@ -0,0 +1,67 @@
+package com.workattech.sw.service;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import com.workattech.sw.models.Money;
+import com.workattech.sw.models.User;
+
+public class PrintService {
+
+ Map> listOfUserWhoOwesToUser;
+ public void printMoneyOwnedByParticularUser(String user,SplitWiseService splitWiseService)
+ {
+ listOfUserWhoOwesToUser=splitWiseService.getlistOfUserWhoOwesToUser();
+ System.out.println("inside print user");
+ boolean borrowerListPrinted=false;
+ System.out.println("lender"+user);
+ for(Entry> userList:listOfUserWhoOwesToUser.entrySet()) {
+ System.out.println("user"+userList.getKey());
+ }
+ if(listOfUserWhoOwesToUser.containsKey(user)) {
+ ArrayList borrowerList=listOfUserWhoOwesToUser.get(user);
+ System.out.println("borrowerList "+borrowerList);
+ for(int i=0;i> userList:listOfUserWhoOwesToUser.entrySet()) {
+ String user=userList.getKey();
+ ArrayList borrowerList=userList.getValue();
+ for(int i=0;i userList=new ArrayList();
+ CalculateExpense calculateExpense=new CalculateExpense();
+ public Map> listOfUserWhoOwesToUser=new HashMap<>();
+ public Map> getlistOfUserWhoOwesToUser()
+ {
+
+ return this.listOfUserWhoOwesToUser;
+ }
+ public void setUserList(ArrayList userList)
+ {
+ this.userList=userList;
+ }
+ public void distributeMoneyIfEqual(ArrayList borrowers,String lender,int amount)
+ {
+
+ double amountToBeDistributed=calculateExpense.CalculateMoneyEqual(amount,borrowers.size()+1);
+ for(int i=0;i borrowers,String lender,ArrayList exactShare)
+ {
+ System.out.println("inside exact");
+ for(int i=0;i borrowers,String lender,int amount,ArrayList PercentShare)
+ {
+ for(int i=0;i moneyBorrowers=listOfUserWhoOwesToUser.get(lender);
+ boolean balanceAddedToBorrower=false;
+ for(int i=0;i moneyBorrowers=new ArrayList();
+ moneyBorrowers.add(new Money(lender,borrower,amountToBeDistributed));
+ listOfUserWhoOwesToUser.put(lender,moneyBorrowers);
+ }
+ }
+ public void subtractMoneyFromBorrowers(String borrower,String lender,double amountToBeDistributed)
+ {
+ if(listOfUserWhoOwesToUser.containsKey(borrower))
+ {
+ ArrayList moneyBorrowers=listOfUserWhoOwesToUser.get(borrower);
+ boolean balanceAddedToBorrower=false;
+ for(int i=0;i