Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h> //HEADER FILES
- #include <conio.h>
- #include <stdlib.h>
- #include <Windows.h>
- void display_main_menu();
- void create_account();
- void modify_account(); //FUNCTION DECLARATIONS
- void make_withdrawal();
- void make_deposit();
- void make_donation();
- void logo();
- FILE *acc; //FILE DECLARATION
- typedef struct
- {
- char firstname[20]; //STRUCTURE
- char lastname[20];
- int payment_type=0;
- int age_calculation;
- int yob;
- char password[30];
- char parish[20];
- float acc_bal=0;
- float acc_fee=0;
- float acc_change=0;
- float withdraw_change=0;
- float account_num;
- }accounts;
- accounts students;
- main() //MAIN STARTS HERE
- {
- SetConsoleTitle("Program done by Nicholas Cameron...Banking Agency");
- int program_pass=2014; //Password needed to access the program
- int pass=0;
- char option;
- float deposit;
- float sav_bal,cur_bal;//for deposit process;
- logo();
- do //CODES FOR ENETRING THE PASSWORD
- {
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
- printf("Enter password ");
- scanf("%d", &pass);
- fflush(stdin);
- if(pass!=program_pass)
- printf("\nAccess Denied! \nPassword incorrect. Please try again ");
- }
- while (pass!=program_pass);
- while (pass==program_pass) // while loop for when password entered is correct
- {
- printf(" \nAccess Granted!\n");
- printf("\n\nPress enter to continue");
- getch();
- system("cls");
- display_main_menu();
- }
- system("pause");
- exit(1);
- }//MAIN ENDS HERE
- //FUNCTION DEFINITIONS
- void display_main_menu() //function display main menu
- {
- main_menu: // goto LABEL FOR MAIN MENU
- system("cls");
- char activity_selection;
- logo();
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 13);
- printf("Please select from the list below the action you wish to carry out\n\n\t");
- printf(" || A. Create an account -(Preferably for new users) ||\n\t");
- printf(" || B. Make a deposit -(for members only) ||\n\t");
- printf(" || C. Make a withdrawal -(for members only) ||\n\t");
- printf(" || D. Modify an account -(for members only) ||\n\t");
- printf(" || E. Make a Donation -(for members only) ||\n\n");
- printf("Enter the letter that corresponds with each option\n");
- scanf("%s",&activity_selection);
- system("cls");
- switch(activity_selection)
- {
- case 'A': case'a':
- create_account();
- break;
- case 'B': case 'b': //DEPOSIT PROCESS
- make_deposit();
- break;
- case 'C': case 'c': //WITHDRAWAL PROCESS
- make_withdrawal();
- break;
- case 'D': case 'd': //Modifying PROCESS
- modify_account();
- break;
- case 'E': case 'e': //DONATION PROCESS
- make_donation();
- default :
- system("cls");
- printf("The choice you entered appears to be invalid\n");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
- printf("\n\t || A.<MAIN MENU> ||\n\t");
- printf(" || B.<EXIT> ||\n\n");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 13);
- printf("Please enter the corresponding letter for the task you wish to execute\n\n\n");
- scanf("%s",&activity_selection);
- if(activity_selection=='A'||activity_selection=='a')
- {
- goto main_menu; //THIS MOVES TO THE MAIN MENU IF 'A' OR 'a' IS ENTERED.DIDNT CALL THE display_main_menu() FUNCTION SINCE WE'RE ALREADY INSIDE IT
- }
- else if(activity_selection=='B'||activity_selection=='b')
- {
- exit(1); //Exits the program if exit is selected
- }
- else
- {
- printf("Another invalid answer option entered.Thank you for trying to use this program\n");
- printf("Press any key to exit\n");
- getch();
- exit(1);
- }
- break;
- }
- }
- void create_account() //function create account
- {
- char decision,new_choice;;
- decision=='y';
- int r;
- srand((unsigned)time(0));//UNSIGNED PREVENTS RANDOM NEGATIVE NUMBERS FROM GENERATING
- r=(rand()*999999999);//THE LARGER NUMBERS INCREASE A CHANCE OF GENERATING LARGER RANDOM NUMBERS WHICH IS MORE SUITABLE FOR A BANKING AGENCY
- r=(rand()%9999999999999)+1;//IF THIS LINE IS ABSENT, THE NUMBERS WONT BE RANDOM ON EACH LOOP, ONLY AFTER THE PROGRAM CLOSES AND RE-OPENS
- int current_year=2014;
- do
- {
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
- printf("This is a list of our current savings plan system which you will choose from\n");
- printf("\n\t || 1. One year ||\n\t");
- printf(" || 2. Two years ||\n\t");
- printf(" || 3. Three years ||\n\t");
- printf(" || 4. Four years ||\n\t");
- printf(" || 5. Five years ||\n\n");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 13);
- printf("Please note...you should enter the corresponding number for the desired savings plan\n");
- printf("You may now enter the savings plan desired\n");
- scanf("%s",&students.payment_type);
- switch(students.payment_type)
- {
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
- case '1':
- printf("You have decided to use a savings plan of 1 year\n");
- break;
- case '2':
- printf("You have decided to use a savings plan of 2 years\n");
- break;
- case '3':
- printf("You have decided to use a savings plan of 3 years\n");
- break;
- case '4':
- printf("You have decided to use a savings plan of 4 years\n");
- break;
- case '5':
- printf("You have decided to use a savings plan of 5 years\n");
- break;
- default:
- system("cls");
- printf("Invalid option entered\n");
- printf("Press any key to continue\n");
- getch();
- system("cls");
- display_main_menu();
- break;
- }
- printf("A minimum opening fee of $100 is required\n");
- printf("Enter the minimum opening fee\n");
- scanf("%f",&students.acc_fee);
- if(students.acc_fee<100)
- {
- printf("The fee entered is too low\n");
- printf("Press enter to return to the main menu\n");
- getch();
- display_main_menu();
- }
- else if(students.acc_fee<=100)
- {
- printf("Your account balance is $%.2f.It will be saved in your creating account\n",students.acc_fee);
- printf("Press enter to continue\n");
- getch();
- }
- else if(students.acc_fee>100)
- {
- students.acc_change=students.acc_fee-100;
- printf("You have an existing change of $%.2f",students.acc_change);
- printf("\nIf you wish to retrieve it, a withdrawal must be made after the account has been created\n");
- printf("Press enter to continue\n");
- getch();
- }
- students.withdraw_change=students.acc_change;
- students.acc_bal=students.acc_fee;
- system("cls");
- printf("it is now time to create an account please enter the information required\n\n");
- printf("enter your firstname\n");
- scanf("%s",&students.firstname);
- printf("enter your lastname\n");
- scanf("%s",&students.lastname);
- printf("Enter the name of your parish\n");
- scanf("%s",&students.parish);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
- printf("\nTo sign up with us, ages must be 18 or older but less than 80 years of age\n");
- printf("You may now enter your year of birth\n");
- scanf("%d",&students.yob);
- students.age_calculation = current_year-students.yob;
- printf("Your age is %d ",students.age_calculation);
- if(students.age_calculation >= 18 && students.age_calculation<=80)
- {
- printf("Which is an acceptable age\n");
- printf("Please enter a password\n");
- scanf("%s",&students.password);
- system("cls");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
- printf("Please Hold, Creating Account...");
- Sleep(3000);
- system("cls");
- printf("Accepting Data....");
- Sleep(300);
- system("cls");
- printf("Enabling Data De-Fragmentation.....");
- Sleep(300);
- system("cls");
- printf("Organizing File Memory...");
- Sleep(300);
- system("cls");
- printf("Initiating Data Logs...");
- Sleep(300);
- system("cls");
- printf("Data Checking...");
- Sleep(300);
- system("cls");
- printf("Initializing Validity Check...");
- Sleep(300);
- system("cls");
- printf("Locating Account Addresses..");
- Sleep(300);
- system("cls");
- printf("Initiating Data Storage...");
- Sleep(300);
- system("cls");
- printf("Finalizing DataBase Entry...");
- Sleep(2000);
- system("cls");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 13);
- printf("Your account has been successfully created!\n");
- printf("You have been assigned the account number : %d\n\n",r);
- printf("Please keep your account number and password safe and confidential for they will be used later for deposits and withdrawals\n\n");
- printf("Your information is as follows:\n");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
- acc=fopen("Active Accounts.txt","a");// FILE HOLDING THE SUCCESSFULLY CREATED ACCOUNTS
- if (acc==NULL)
- {
- printf("Error opening file!\n");
- exit(1);
- }
- fprintf(acc,">> Account # : %d\n",r);
- fprintf(acc,">> First Name : %s\n",students.firstname);
- fprintf(acc,">> Last Name : %s\n",students.lastname);
- fprintf(acc,">> Parish : %s\n",students.parish);
- fprintf(acc,">> Year of Birth : %d\n",students.yob);
- fprintf(acc,">> Age : %d\n",students.age_calculation);
- fprintf(acc,">> Savings Period : %d year(s)\n",students.payment_type);
- fprintf(acc,">> Password : %s\n",students.password);
- fprintf(acc,">> Change(left from fee paid) : $%.2f\n",students.withdraw_change);
- fprintf(acc,">> Account balance : $%.2f\n",students.acc_bal);
- fprintf(acc,"======================================================\n");
- fclose(acc);
- printf("================================================================================");
- printf(" >> Account # : %d\n",r);
- printf(" >> First Name : %s\n",students.firstname);
- printf(" >> Last Name : %s\n",students.lastname);
- printf(" >> Parish : %s\n",students.parish);
- printf(" >> Year of Birth : %d\n",students.yob);
- printf(" >> Age : %d\n",students.age_calculation);
- printf(" >> Savings Period : %d year(s)\n",students.payment_type);
- printf(" >> Password : %s\n",students.password);
- printf(" >> Change(left from fee paid) : $%.2f\n",students.withdraw_change);
- printf(" >> Account balance : $%.2f\n",students.acc_bal);
- printf("================================================================================\n");
- }
- else if(students.age_calculation >=80)
- {
- printf("Were very sorry but you are too old to create an account with us\n\n");
- }
- else
- {
- printf("You are too young to create an account here sorry\n\n");
- }
- printf("If a mistake was made you can repeat the procedure of creating another savings\n");
- printf("account\n\n");
- printf("Do you wish to repeat? <y or n>\n\n");
- scanf("%s",&decision);
- system("cls");
- }
- while(decision=='Y'||decision=='y');
- if(decision=='N'||decision=='n')
- {
- printf("You are now a member of this banking agency! ....\n");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
- main_or_exit:
- printf("\n\t || A.<MAIN MENU> ||\n\t");
- printf(" || B.<EXIT> ||\n\n");
- printf("Please select the desired option <a or b>\n\n");
- scanf("%s",&new_choice);
- if(new_choice=='A'||new_choice=='a')
- {
- display_main_menu();
- }
- else if(new_choice=='B'||new_choice=='b')
- {
- exit(1);
- }
- else
- {
- system("cls");
- printf("Invalid option entered\n");
- printf("Please read carefully and re-enter the option desired\n");
- goto main_or_exit;
- }
- }
- }
- void make_withdrawal() //function make a withdrawal from an account
- {
- system("cls");
- logo();
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 13);
- printf("\n\nWITHDRAWAL PROCESSING IS DONE HERE\n\n");
- printf("Please enter your account number");
- scanf("%d",&students.account_num);
- }
- void make_deposit() //function make deposit to an account
- {
- system("cls");
- logo();
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 13);
- printf("\n\nDEPOSIT PROCESSING IS DONE HERE\n\n");
- printf("Please enter your account number");
- scanf("%d",&students.account_num);
- //fp=fopen("Active Accounts.txt","r");
- //fseek(fp,0L,0);
- /*if(account_num==r)
- {
- printf("Enter the amount of money to be deposited");
- scanf("%f",&deposit);
- acc_bal=acc_bal+deposit;
- printf("%.2f",acc_bal);
- }*/
- }
- void modify_account() //function modify an account
- {
- system("cls");
- logo();
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 13);
- int id;
- printf("\n\nMODIFYING ACCOUNTS IS DONE HERE\n\n");
- printf("Please enter your account number");
- scanf("%d",&id);
- }
- void make_donation() //function make a donation to the bank
- {
- system("cls");
- logo();
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 13);
- int id;
- printf("\n\nDONATION PROCESSING IS DONE HERE\n\n");
- printf("Please enter your account number");
- scanf("%d",&id);
- }
- void logo()
- {
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
- printf("\t =================================================== \n\t");
- printf(" @@@@@@@@@@ THE OLD HARBOUR @@@@@@@@@@@@@@@@ \n\t");
- printf(" @@@@@@@@@@ HIGH SCHOOL BANKING @@@@@@@@@@@@@@@@ \n\t");
- printf(" @@@@@@@@@@ SYSTEM @@@@@@@@@@@@@@@@ \n\t");
- printf(" =================================================== \n\n");
- }
Add Comment
Please, Sign In to add comment