Question
write a code on .C file

Problem Write a C program to implement a banking application system. The program design must use a main and the below functio
Credit Amt: The amount deposited to the account. Debit Amt: The amount withdrawn from the account. The maximum number of line
2. Define a non-void function OAuthentication_05 that takes a 2D array Account_Status, integer Customer_ID, integer PIN, and
• If the user chooses option A, the main function must call the function O_NewAccount_05. • If the user chooses option B, the
When user enter Cor D: Please choose one of the following A: Open New Account B: Search for Account C: View Account Statement
O_Customerdata_05 - Notepad File Edit Format View Help 2345 123 Joe 3456 345 Li Doe Mew 56787667 56783422 4500 6000
O_Logs_05 - Notepad File Edit Format View Help 2345 2 3 3456 4. 2.
O_Transactions_History_05 - Notepad File Edit Format View Help 12345 150 2345 200 3456 450 2345 350


Problem Write a C program to implement a banking application system. The program design must use a main and the below functio
Credit Amt: The amount deposited to the account. Debit Amt: The amount withdrawn from the account. The maximum number of line
2. Define a non-void function OAuthentication_05 that takes a 2D array Account_Status, integer Customer_ID, integer PIN, and
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:-


#include <stdio.h>

#include<stdlib.h>

#define row 28

const int col=3;

int cur_cd=0,cur_log=0,cur_ts=0;

int Login_PIN[row];

int Account_status[row][3];

char Name[row][100];

struct Logs

{

int cid,ls,lf;

}L[row];

struct Transaction

{

int cid,c_amnt,d_amnt;

}TH[row];

int f=1;

void input()

{

FILE *fin;

fin=fopen("O_Customerdata_04.txt","r");

if ( fin == NULL )

{

printf("No file named O_Customerdata_04\n") ;

f=0;

return;

}

int i=0;

char fn[50],ln[50];

while(fscanf(fin,"%d%d",&Account_status[i][0],&Login_PIN[i])!=EOF)

{

fscanf(fin,"%s%s",fn,ln);

int sfn=0,sln=0;

while(fn[sfn]!='\0')

{

sfn++;

}

while(ln[sln]!='\0')

{

sln++;

}

int k;

for(k=0;k<sfn;k++)

{

Name[i][k]=fn[k];

}

Name[i][k]=' ';

k++;

int j;

for(j=0;j<sln;j++,k++)

{

Name[i][k]=ln[j];

}

Name[i][k]='\0';

fscanf(fin,"%d%d",&Account_status[i][1],&Account_status[i][2]);

//printf("%d %s %d\n",Account_status[i][0],Name[i],Account_status[i][1]);

i++;

}

cur_cd=i;

fclose(fin);

fin=fopen("O_Logs_04.txt","r");

if ( fin == NULL )

{

printf("No file named O_Logs_04\n") ;

f=0;

return;

}

i=0;

while(fscanf(fin,"%d%d%d",&L[i].cid,&L[i].ls,&L[i].lf)!=EOF)

{

i++;

}

cur_log=i;

fclose(fin);

fin=fopen("O_Transaction_History_04.txt","r");

if ( fin == NULL )

{

printf("No file named O_Transaction_History_04\n") ;

f=0;

return;

}

i=0;

while(fscanf(fin,"%d%d%d",&TH[i].cid,&TH[i].c_amnt,&TH[i].d_amnt)!=EOF)

{

i++;

}

cur_ts=i;

fclose(fin);

return;

}

void O_NewAccount_04()

{

if(cur_cd>27)

{

printf("The File is Full cannot create a new account\n\n");

return;

}

int id,i;

printf("Enter a new Customer ID:");

scanf("%d",&id);

for(i=0;i<cur_cd;i++)

{

if(id==Account_status[i][0])

{

break;

}

}

if(i!=cur_cd)

{

printf("Customer ID Already Exisits.New Account is not created\n\n");

return;

}

while ((getchar()) != '\n');

char fn[50],ln[50];

printf("Enter First Name:");

scanf("%s",fn);

printf("Enter Last Name:");

scanf("%s",ln);

int phn_num,damnt;

printf("Enter Phone Number:");

scanf("%d",&phn_num);

printf("Enter Initial deposit amount:");

scanf("%d",&damnt);

if(damnt<530)

{

printf("Minimum balance must be 530.New Account is not created\n\n");

return;

}

i=cur_cd;

Account_status[cur_cd][0]=id;

int sfn=0,sln=0;

while(fn[sfn]!='\0')

{

sfn++;

}

while(ln[sln]!='\0')

{

sln++;

}

int k;

for(k=0;k<sfn;k++)

{

Name[i][k]=fn[k];

}

Name[i][k]=' ';

k++;

int j;

for(j=0;j<sln;j++,k++)

{

Name[i][k]=ln[j];

}

Name[i][k]='\0';

Account_status[cur_cd][1]=phn_num;

Account_status[cur_cd][2]=damnt;

printf("Enter a 3 digit Pin:");

scanf("%d",&Login_PIN[cur_cd]);

L[cur_log].cid=id;

L[cur_log].ls=L[cur_log].lf=0;

printf("Your Account has been created successfully\n\n");

cur_cd++;

cur_log++;

return;

}

void O_Search_04()

{

int id,pin;

printf("Enter Customer Id:");

scanf("%d",&id);

int i;

for(i=0;i<cur_cd;i++)

{

//printf("%d\n",Account_status[i][0]);

if(id==Account_status[i][0])

{

break;

}

}

if(i==cur_cd)

{

printf("Id not present\n\n");

return;

}

int j;

for(j=0;j<cur_log;j++)

{

if(L[j].cid==id)

{

break;

}

}

printf("Enter Customer PIN:");

scanf("%d",&pin);

if(Login_PIN[i]!=pin)

{

printf("Wrong PIN\n\n");

L[j].lf++;

return;

}

L[j].ls++;

printf("\tName\t:%s\n",Name[i]);

printf("\tPhone\t:%d\n",Account_status[i][1]);

printf("\tBalance\t:%d\n",Account_status[i][2]);

printf("\n");

return;

}

void O_Statement_04()

{

int id,pin;

printf("Enter Customer Id:");

scanf("%d",&id);

int i;

for(i=0;i<cur_cd;i++)

{

//printf("%d\n",Account_status[i][0]);

if(id==Account_status[i][0])

{

break;

}

}

if(i==cur_cd)

{

printf("Id not present\n\n");

return;

}

int j;

for(j=0;j<cur_log;j++)

{

if(L[j].cid==id)

{

break;

}

}

printf("Enter Customer PIN:");

scanf("%d",&pin);

if(Login_PIN[i]!=pin)

{

printf("Wrong PIN\n\n");

L[j].lf++;

return;

}

L[j].ls++;

printf("Customer Id\t\tCredit Amount\t\tDebit Amount\n");

printf("-----------\t\t-------------\t\t-------------\n");

for(int i=0;i<cur_ts;i++)

{

if(id==TH[i].cid)

{

printf("%d\t\t\t%d\t\t\t\t\t%d\n",TH[i].cid,TH[i].c_amnt,TH[i].d_amnt);

}

}

printf("\n");

}

void O_Transaction_04()

{

if(cur_ts>27)

{

printf("The File is Full cannot create a new transaction\n\n");

return;

}

int id,pin;

printf("Enter Customer Id:");

scanf("%d",&id);

int i;

for(i=0;i<cur_cd;i++)

{

//printf("%d\n",Account_status[i][0]);

if(id==Account_status[i][0])

{

break;

}

}

if(i==cur_cd)

{

printf("Id not present\n\n");

return;

}

int j;

for(j=0;j<cur_log;j++)

{

if(L[j].cid==id)

{

break;

}

}

printf("Enter Customer PIN:");

scanf("%d",&pin);

if(Login_PIN[i]!=pin)

{

printf("Wrong PIN\n\n");

L[j].lf++;

return;

}

L[j].ls++;

printf("Enter Your Option\n");

printf("\t1. Deposit\n");

printf("\t2. Withdrawl\n");

int ch,amnt;

scanf("%d",&ch);

if(ch==1)

{

printf("Enter amount to be deposited:");

scanf("%d",&amnt);

TH[cur_ts].cid=id;

TH[cur_ts].c_amnt=amnt;

TH[cur_ts].d_amnt=0;

Account_status[i][2]+=amnt;

printf("\tYour Account has been Credited for amount %d\n",amnt);

printf("\tCurrent Balance in Your account %d\n\n",Account_status[i][2]);

cur_ts++;

}

else

{

printf("Enter amount to be withdrawn:");

scanf("%d",&amnt);

if(Account_status[i][2]-amnt<530)

{

printf("Transaction Failed amount more than minimum balance\n\n");

L[j].ls--;

L[j].lf++;

return;

}

TH[cur_ts].cid=id;

TH[cur_ts].c_amnt=0;

TH[cur_ts].d_amnt=amnt;

Account_status[i][2]-=amnt;

printf("\tYour Account has been Debited for amount %d\n",amnt);

printf("\tCurrent Balance in Your account %d\n\n",Account_status[i][2]);

cur_ts++;

}

}

void output()

{

FILE *fout;

fout=fopen("O_Customerdata_04.txt","w");

int i;

for(int i=0;i<cur_cd;i++)

{

fprintf(fout,"%d %d %s %d %d\n",Account_status[i][0],Login_PIN[i],Name[i],Account_status[i][1],Account_status[i][2]);

}

fclose(fout);

fout=fopen("O_Logs_04.txt","w");

for(int i=0;i<cur_log;i++)

{

fprintf(fout,"%d %d %d\n",L[i].cid,L[i].ls,L[i].lf);

}

fclose(fout);

fout=fopen("O_Transaction_History_04.txt","w");

for(int i=0;i<cur_ts;i++)

{

fprintf(fout,"%d %d %d\n",TH[i].cid,TH[i].c_amnt,TH[i].d_amnt);

}

fclose(fout);

return;

}

int main(void)

{

input();

if(f==0)

{

return 0;

}

while(f)

{

printf("Please choose one of the following ---\n");

printf("A: Open New Account\n");

printf("B: Search for Account\n");

printf("C: View Account Statement\n");

printf("D: Perform Transaction\n");

printf("E: Exit\n");

char ch;

printf("Enter Your Option: ");

scanf("%c",&ch);

switch(ch)

{

case 'A':

O_NewAccount_04();

break;

case 'B':

O_Search_04();

break;

case 'C':

O_Statement_04();

break;

case 'D':

O_Transaction_04();

break;

case 'E':

f=0;

break;

}

while ((getchar()) != '\n');

}

output();

return 0;

}

Output:-

Please choose one of the following A: Open New Account B: Search for Account C: View Account Statement D: Perform TransactionPlease choose one of the following A: Open New Account B: Search for Account C: View Account Statement D: Perform TransactionPlease choose one of the following --- A: Open New Account B: Search for Account C: View Account Statement D: Perform Transac

Please UPVOTE thank you...!!!

Comment if you have any doubts or modifications thank you...!!!

Add a comment
Know the answer?
Add Answer to:
write a code on .C file Problem Write a C program to implement a banking application...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program **(IN C)** that displays all the phone numbers in a file that match the area code...

    Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...

  • Exercise 6: Program exercise for 2D List Write a complete Python program including minimal comments (file...

    Exercise 6: Program exercise for 2D List Write a complete Python program including minimal comments (file name, your name, and problem description) that solves the following problem with the main function: Problem Specification: The following code reads values from the file object infile and stores them in the 2d list table2: (It assumes that each line contains values of elements in each row and the values are whitespace separated.) table2 = [] for line in infile: row=line.split() intRow = []...

  • The name of the C++ file must be search.cpp Write a program that will read data...

    The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...

  • Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a...

    Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a main function and three other functions called. readmarks , changemarks (, and writemarks() The program begins by calling the function readmarks () to read the input file marksin. txt which consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float). Once the ID numbers and marks have been read into arrays (by readmarks () the...

  • C++ program Write a C++ program to manage a hospital system, the system mainly uses file...

    C++ program Write a C++ program to manage a hospital system, the system mainly uses file handling to perform basic operations like how to add, edit, search, and delete record. Write the following functions: 1. hospital_menu: This function will display the following menu and prompt the user to enter her/his option. The system will keep showing the menu repeatedly until the user selects option 'e' from the menu. Arkansas Children Hospital a. Add new patient record b. Search record c....

  • Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a funct...

    Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...

  • Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that...

    Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...

  • WRITE A JAVA CODE

    Create a communication information system for a company with using Red-Black Tree Method. In this system the users are allowed to search an employee from employee's registration number(id) and retreive the department number(id) and that employee's internal phone number. Also, if the employee they are looking for is not in the tree, they can add it. (in accordance with the red-black tree properties)a) Implement the Employee class:- Registration number (an integer)- Department ID (an integer)- Internal Phone Number (an integer)...

  • Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The progra...

    Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...

  • In C++, Write a program that retrieves a phone number from a txt files of names...

    In C++, Write a program that retrieves a phone number from a txt files of names and phone numbers. The program should ask the user to enter a name and then print the phone number of that person (or vice versa, number into name) The program should allow the user to repeat the operation as often as they would like to. The data is contained in two text files named "phoneNames.txt" and "phoneNums.txt". The files have one name or one...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT