Last active
December 8, 2019 08:37
-
-
Save Gabutoo/4d0aaff9640c0706718f879cca3afb8e to your computer and use it in GitHub Desktop.
Banking (User Menu) using Linked List with ADD MODIFY DELETE DISPLAY (Admin Menu)
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
| #include<stdio.h> | |
| #include<conio.h> | |
| #include<stdlib.h> | |
| #include<malloc.h> | |
| #include<malloc.h> | |
| #include<string.h> | |
| struct bank{ | |
| char name[50]; | |
| int password = 0; | |
| double money = 0.0; | |
| struct bank *next; | |
| }; | |
| struct bank* b; | |
| // PROTOTYPES | |
| void getPin(int password); | |
| void bankMenu(); | |
| void getBalance(); | |
| void withdrawMoney(); | |
| void depositMoney(); | |
| void changePin(); | |
| int main() | |
| { | |
| int comm; | |
| printf("WELCOME TO GBS BANK!"); | |
| getPin(int password); | |
| printf("[1] USER BANKING MENU"); | |
| printf("[2] ADMINISTRATOR"); | |
| scanf("%d",&comm); | |
| switch(comm) | |
| { | |
| case 1: | |
| bankMenu(); | |
| break; | |
| case 2: | |
| adminMenu(); | |
| break; | |
| } | |
| getch(); | |
| return 0; | |
| } | |
| void getPin(int password) | |
| { | |
| int pin; | |
| printf("Enter your 6 digit PIN: "); | |
| scanf("%d",&pin); | |
| if(bank.password == pin) | |
| { | |
| bankMenu(); | |
| } | |
| else | |
| { | |
| printf("Incorrect Pin Entered! Try Again!"); | |
| getPin(int password); | |
| } | |
| void adminMenu() | |
| { | |
| int comm2; | |
| printf("\n*****ADMINISTRATOR*****"); | |
| printf("\n[1] ADD"); | |
| printf("\n[2] DELETE"); | |
| printf("\n[3] MODIFY); | |
| printf("\n[4] DISPLAY"); | |
| scanf("%d",&comm2); | |
| switch(comm2) | |
| { | |
| case 1: | |
| break; | |
| case 2: | |
| case 3: | |
| case 4: | |
| break; | |
| } | |
| } | |
| void bankMenu() | |
| { | |
| int command; | |
| printf("*****USER MENU*****") | |
| printf("\n[1] Check Balance"); | |
| printf("\n[2] Withdrawal"); | |
| printf("\n[3] Deposit"); | |
| printf("\n[4] Change PIN"); | |
| printf("\n[5] EXIT"); | |
| printf("Enter command: "); | |
| scanf("%d",&command); | |
| switch(command) | |
| { | |
| case 1: | |
| printf("\n*****CHECK BALANCE*****"); | |
| getBalance(); | |
| break; | |
| case 2: | |
| printf("\n*****WITHDRAWAL*****"); | |
| withdrawMoney(); | |
| break; | |
| case 3: | |
| printf("\n*****DEPOSIT*****"); | |
| depositMoney(); | |
| break; | |
| case 4: | |
| printf("\n*****CHANGE PIN*****"); | |
| changePin(); | |
| break; | |
| case 5: | |
| printf("*****EXIT*****"); | |
| printf("Thank You!"); | |
| break; | |
| default: | |
| printf("Command Not Found!"); | |
| break; | |
| } | |
| } | |
| void getBalance() | |
| { | |
| char choice[10]; | |
| printf("Your current account balance is: Php %d ",money); | |
| printf("Do you want to back to Main Menu? [Y/N]: "); | |
| scanf("%s",&choice); | |
| if(choice == 'Y' || choice =='y') | |
| { | |
| bankMenu(); | |
| } | |
| else | |
| { | |
| printf("Please Wait . . . \n Saving Changes . . ."); | |
| printf("Thank You for using GBS Bank!"); | |
| } | |
| } | |
| void withdrawMoney() | |
| { | |
| double withdraw; | |
| printf("Enter amount you want to withdraw: "); | |
| scan("%d",&withdraw); | |
| if(withdraw >= money) | |
| { | |
| money -= withdraw; | |
| } | |
| else | |
| { | |
| printf("Insufficient Balance!"); | |
| } | |
| printf("Your current account balance is: Php %d ",money); | |
| char choice[10]; | |
| printf("Do you want to back to Main Menu? [Y/N]: "); | |
| scanf("%c",&choice); | |
| if(choice == 'Y' || choice =='y') | |
| { | |
| bankMenu(); | |
| } | |
| else | |
| { | |
| printf("Please Wait . . . \n Saving Changes . . ."); | |
| printf("Thank You for using GBS Bank!"); | |
| } | |
| } | |
| void depositMoney() | |
| { | |
| double deposit; | |
| printf("Enter amount to deposit: "); | |
| scanf("%d",&deposit); | |
| money = money + deposit; | |
| printf("Your current account balance is: %d",money); | |
| char choice[10]; | |
| printf("Do you want to back to Main Menu? [Y/N]: "); | |
| scanf("%c",&choice); | |
| if(choice == 'Y' || choice == 'y') | |
| { | |
| bankMenu(); | |
| } | |
| else | |
| { | |
| printf("Please Wait . . . \n Saving Changes . . ."); | |
| printf("Thank You for using GBS Bank!"); | |
| } | |
| } | |
| void changePin() | |
| { | |
| int inputPin; | |
| printf("Please your current 6 digit pin: "); | |
| scanf("%d",&inputPin); | |
| int newPin; | |
| if(password == inputPin) | |
| { | |
| printf("Enter your new 6 digit pin: "); | |
| scanf("%d",newPin); | |
| if(newPin > 999999) | |
| { | |
| printf("only 6 digit characters are allowed!"); | |
| changePin(); | |
| } | |
| else | |
| { | |
| password = newPin; | |
| bankMenu(); | |
| } | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment