Created
December 8, 2019 07:36
-
-
Save Gabutoo/7fd62d3e62230144619c8deb8eba560c 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> | |
| double money = 0.0; | |
| struct bank{ | |
| int password = 0; | |
| struct bank *next; | |
| }; | |
| struct bank* b; | |
| // PROTOTYPES | |
| void getPin(int password); | |
| void bankMenu(); | |
| void getBalance(); | |
| void withdrawMoney(); | |
| void depositMoney(); | |
| void changePin(); | |
| int main() | |
| { | |
| printf("WELCOME TO GBS BANK!"); | |
| getPin(int password); | |
| 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 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("\n*****ADMINISTRATOR*****"); | |
| printf("\n[6] ADD"); | |
| printf("\n[7] DELETE"); | |
| printf("\n[8] MODIFY); | |
| printf("\n[9] DISPLAY"); | |
| 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