Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int balance1 = 0;
- int balance2 = 0;
- int balance3 = 0;
- int balance4 = 0;
- int balance5 = 0;
- void sendTransactions() {
- printf("Transactions Available\n");
- printf("1. Deposit\n");
- printf("2. Withdraw\n");
- printf("3. Transfer Funds\n");
- printf("4. Check Balance\n");
- printf("5. Main Menu\n");
- printf("*********************\n");
- }
- char getName(int id) {
- switch(id) {
- case 1:
- return 'RJ Dequina';
- break;
- case 2:
- return 'Raymart Sarmiento';
- break;
- case 3:
- return 'Arreza Ronnel';
- break;
- case 4:
- return 'Maersk Caddarao';
- break;
- case 5:
- return 'Clyde Lamina';
- break;
- }
- }
- void formatMessage(int id, char text[], int balance) {
- switch(id) {
- case 1:
- printf("*********************\n");
- printf("Account Name: RJ Dequina\n");
- printf("Current Balance: %d\n", balance1);
- printf("%s", text);
- printf("\n");
- printf("*********************\n");
- break;
- case 2:
- printf("*********************\n");
- printf("Account Name: Raymart Sarmiento\n");
- printf("Current Balance: %d\n", balance2);
- printf("%s", text);
- printf("\n");
- printf("*********************\n");
- break;
- case 3:
- printf("*********************\n");
- printf("Account Name: Arreza Ronnel\n");
- printf("Current Balance: %d\n", balance3);
- printf("%s", text);
- printf("\n");
- printf("*********************\n");
- break;
- case 4:
- printf("*********************\n");
- printf("Account Name: Maersk Caddarao\n");
- printf("Current Balance: %d\n", balance4);
- printf("%s", text);
- printf("\n");
- printf("*********************\n");
- break;
- case 5:
- printf("*********************\n");
- printf("Account Name: Clyde Lamina\n");
- printf("Current Balance: %d\n", balance5);
- printf("%s", text);
- printf("\n");
- printf("*********************\n");
- break;
- }
- }
- void clearScreen() {
- system("cls");
- }
- void dealTransaction(int id, int balance) {
- int choice;
- int amount;
- int chosenId;
- scanf("%d", &choice);
- switch(choice) {
- case 1:
- amount = 0;
- formatMessage(id, "Enter Amount to Deposit", balance);
- scanf("%d", &amount);
- balance += amount;
- formatMessage(id, "", balance);
- sendTransactions();
- dealTransaction(id, balance);
- break;
- case 2:
- amount = 0;
- formatMessage(id, "Enter Amount to Withdraw", balance);
- scanf("%d", &amount);
- if(amount > balance) {
- formatMessage(id, "Unsuccessful Transaction", balance);
- sendTransactions();
- dealTransaction(id, balance);
- } else {
- balance -= amount;
- formatMessage(id, "Successful Transaction", balance);
- sendTransactions();
- dealTransaction(id, balance);
- }
- formatMessage(id, "", balance);
- sendTransactions();
- dealTransaction(id, balance);
- break;
- case 3:
- amount = 0;
- formatMessage(id, "Enter account number you wish to transfer funds", balance);
- scanf("%d", &amount);
- if(amount == id) {
- formatMessage(id, "You cannot transfer to yourself", balance);
- sendTransactions();
- dealTransaction(id, balance);
- }else {
- if(amount < 1 || amount > 5) {
- formatMessage(id, "Unsuccessful Transaction", balance);
- sendTransactions();
- dealTransaction(id, balance);
- }else {
- int number = 0;
- formatMessage(id, "How much you want to transfer to this account", balance);
- scanf("%d", &number);
- if(number > balance) {
- formatMessage(id, "Inssuficient Balance", balance);
- sendTransactions();
- dealTransaction(id, balance);
- }else {
- switch(amount) {
- case 1:
- balance1+=number;
- break;
- case 2:
- balance2+=number;
- break;
- case 3:
- balance3+=number;
- break;
- case 4:
- balance4+=number;
- break;
- case 5:
- balance5+=number;
- break;
- }
- balance-=number;
- formatMessage(id, "Successful Transaction", balance);
- sendTransactions();
- dealTransaction(id, balance);
- }
- }
- }
- break;
- case 4:
- formatMessage(id, "", balance);
- sendTransactions();
- dealTransaction(id, balance);
- break;
- case 5:
- printf("*********************\n");
- printf("Enter any account ID to start the transaction\n");
- printf("1. RJ Dequina\n");
- printf("2. Raymart Sarmiento\n");
- printf("3. Arreza Ronnel\n");
- printf("4. Maersk Caddarao\n");
- printf("5. Clyde Lamina\n");
- printf("*********************\n");
- scanf("%d", &chosenId);
- switch(chosenId) {
- case 1:
- formatMessage(1, "", balance1);
- sendTransactions();
- dealTransaction(1, balance1);
- break;
- case 2:
- formatMessage(2, "", balance2);
- sendTransactions();
- dealTransaction(2, balance2);
- break;
- case 3:
- formatMessage(3, "", balance3);
- sendTransactions();
- dealTransaction(3, balance3);
- break;
- case 4:
- formatMessage(4, "", balance4);
- sendTransactions();
- dealTransaction(4, balance4);
- break;
- case 5:
- formatMessage(5, "", balance5);
- sendTransactions();
- dealTransaction(5, balance5);
- break;
- }
- break;
- }
- }
- int main() {
- int chosenId;
- printf("*********************\n");
- printf("Enter any account ID to start the transaction\n");
- printf("1. RJ Dequina\n");
- printf("2. Raymart Sarmiento\n");
- printf("3. Arreza Ronnel\n");
- printf("4. Maersk Caddarao\n");
- printf("5. Clyde Lamina\n");
- printf("*********************\n");
- scanf("%d", &chosenId);
- switch(chosenId) {
- case 1:
- formatMessage(1, "", balance1);
- sendTransactions();
- dealTransaction(1, balance1);
- break;
- case 2:
- formatMessage(2, "", balance2);
- sendTransactions();
- dealTransaction(2, balance2);
- break;
- case 3:
- formatMessage(3, "", balance3);
- sendTransactions();
- dealTransaction(3, balance3);
- break;
- case 4:
- formatMessage(4, "", balance4);
- sendTransactions();
- dealTransaction(4, balance4);
- break;
- case 5:
- formatMessage(5, "", balance5);
- sendTransactions();
- dealTransaction(5, balance5);
- break;
- }
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement