This repository was archived by the owner on May 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
solved the problem #5
Open
Susmita-code007
wants to merge
1
commit into
workattech:master
Choose a base branch
from
Susmita-code007:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #include "split_service.h" | ||
|
|
||
| int main() | ||
| { | ||
| SplitService *ser = new SplitService(4); | ||
|
|
||
| User *U1 = new User(0, "u1", "Susmita", "sm@com", "11890"); | ||
| ser->set_user_table("u1", U1); | ||
|
|
||
| User *U2 = new User(1, "u2", "Ayan", "ay@com", "11890"); | ||
| ser->set_user_table("u2", U2); | ||
|
|
||
| User *U3 = new User(2, "u3", "Moumita", "mm@com", "11890"); | ||
| ser->set_user_table("u3", U3); | ||
|
|
||
| User *U4 = new User(3, "u4", "Subhayan", "sb@com", "11890"); | ||
| ser->set_user_table("u4", U4); | ||
|
|
||
| int cont = 0; | ||
| do{ | ||
| cout << "Enter operation " << endl; | ||
| string op; | ||
| cin >> op; | ||
| if (op == "SHOW") | ||
| { | ||
| cout << "for a specific user?" << endl; | ||
| string ans; | ||
| cin >> ans; | ||
| if (ans == "YES" || ans == "Yes" || ans == "yes") | ||
| { | ||
| cout << "Enter user id" << endl; | ||
| string u; | ||
| cin >> u; | ||
| ser->SHOW(u, 0); | ||
| } | ||
| else | ||
| { | ||
| ser->SHOW_ALL(); | ||
| } | ||
| } | ||
| else if (op == "EXPENSE") | ||
| { | ||
| int num = 0; | ||
| string payer; | ||
| vector <string> users; | ||
| string type; | ||
| int total; | ||
| cout << "Enter payer " << endl; | ||
| cin >> payer; | ||
| cout << "Enter total " << endl; | ||
| cin >> total; | ||
| cout << "Enter no of users " << endl; | ||
| cin >> num; | ||
| cout << "enter user_ids " << endl; | ||
| for (int i = 0; i<num; i++) | ||
| { | ||
| string u; | ||
| cin >> u; | ||
| users.push_back(u); | ||
| } | ||
| cout << "Enter type of expense, EXACT, EQUAL or PERCENT " << endl; | ||
| cin >> type; | ||
| if (type == "EQUAL") | ||
| ser->EXPENSE_EQUAL(total, payer, users); | ||
| else if (type == "EXACT") | ||
| { | ||
| cout << "Enter amounts " << endl; | ||
| vector <int> amounts; | ||
| for (int i = 0; i<num; i++) | ||
| { | ||
| int amount; | ||
| cin >> amount; | ||
| amounts.push_back(amount); | ||
| } | ||
| ser->EXPENSE_EXACT(total, payer, users, amounts); | ||
| } | ||
| else if (type == "PERCENT") | ||
| { | ||
| cout << "Enter percents " << endl; | ||
| vector <float> percents; | ||
| for (int i = 0; i<num; i++) | ||
| { | ||
| float percent; | ||
| cin >> percent; | ||
| percents.push_back(percent); | ||
| } | ||
| ser->EXPENSE_PERCENT(total, payer, users, percents); | ||
| } | ||
| else | ||
| cout << "INVALID TYPE" << endl; | ||
| } | ||
| else | ||
| cout << "INVALID OPERTAION " << endl; | ||
|
|
||
| cout << "Press 1 to continue" << endl; | ||
| cin >> cont; | ||
| }while (cont == 1); | ||
|
|
||
| return 0; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| n | ||
| No balances | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| YES | ||
| Enter user id | ||
| u1 | ||
| No balances | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| EXPENSE | ||
| Enter payer | ||
| u2 | ||
| Enter total | ||
| 1000 | ||
| Enter no of users | ||
| 4 | ||
| enter user_ids | ||
| u1 u2 u3 u4 | ||
| Enter type of expense, EXACT, EQUAL or PERCENT | ||
| EQUAL | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| yes | ||
| Enter user id | ||
| u1 | ||
| u1 owes u2: 250 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| yes | ||
| Enter user id | ||
| u2 | ||
| u1 owes u2: 250 | ||
| u3 owes u2: 250 | ||
| u4 owes u2: 250 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| n | ||
| u1 owes u2: 250 | ||
| u3 owes u2: 250 | ||
| u4 owes u2: 250 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| EXPENSE | ||
| Enter payer | ||
| u3 | ||
| Enter total | ||
| 2000 | ||
| Enter no of users | ||
| 3 | ||
| enter user_ids | ||
| u1 u2 u4 | ||
| Enter type of expense, EXACT, EQUAL or PERCENT | ||
| EXACT | ||
| Enter amounts | ||
| 1000 500 500 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| yes | ||
| Enter user id | ||
| u3 | ||
| u1 owes u3: 1000 | ||
| u2 owes u3: 250 | ||
| u4 owes u3: 500 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| EXPENSE | ||
| Enter payer | ||
| u1 | ||
| Enter total | ||
| 1000 | ||
| Enter no of users | ||
| 1 | ||
| enter user_ids | ||
| u3 | ||
| Enter type of expense, EXACT, EQUAL or PERCENT | ||
| PERCENT | ||
| Enter percents | ||
| 100 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| yes | ||
| Enter user id | ||
| u1 | ||
| u1 owes u2: 250 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| yes | ||
| Enter user id | ||
| u3 | ||
| u2 owes u3: 250 | ||
| u4 owes u3: 500 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| EXPENSE | ||
| Enter payer | ||
| u2 | ||
| Enter total | ||
| 250 | ||
| Enter no of users | ||
| 1 | ||
| enter user_ids | ||
| u3 | ||
| Enter type of expense, EXACT, EQUAL or PERCENT | ||
| EXACT | ||
| Enter amounts | ||
| 250 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| n | ||
| u1 owes u2: 250 | ||
| u4 owes u2: 250 | ||
| u4 owes u3: 500 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| EXPENSE | ||
| Enter payer | ||
| u4 | ||
| Enter total | ||
| 750 | ||
| Enter no of users | ||
| 2 | ||
| enter user_ids | ||
| u2 u3 | ||
| Enter type of expense, EXACT, EQUAL or PERCENT | ||
| PERCENT | ||
| Enter percents | ||
| 25 70 | ||
| invalid_entry!!! | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| EXPENSE | ||
| Enter payer | ||
| u4 | ||
| Enter total | ||
| 750 | ||
| Enter no of users | ||
| 2 | ||
| enter user_ids | ||
| u2 u3 | ||
| Enter type of expense, EXACT, EQUAL or PERCENT | ||
| EXACT | ||
| Enter amounts | ||
| 250 500 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| n | ||
| u1 owes u2: 250 | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| EXPENSE | ||
| Enter payer | ||
| u1 | ||
| Enter total | ||
| 250 | ||
| Enter no of users | ||
| 1 | ||
| enter user_ids | ||
| u2 | ||
| Enter type of expense, EXACT, EQUAL or PERCENT | ||
| EQUAL | ||
| Press 1 to continue | ||
| 1 | ||
| Enter operation | ||
| SHOW | ||
| for a specific user? | ||
| n | ||
| No balances | ||
| Press 1 to continue | ||
| 0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should follow the same format as mentioned in the problem statement at least during the interview.