Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE CONVERT IT INTO COBOL PROGRAM #include struct customer { int account_no; char name[80]; int balance; }; void accept(struct customer[], int); void display(struct customer[], int);

PLEASE CONVERT IT INTO COBOL PROGRAM

#include

struct customer

{ int account_no; char name[80]; int balance; };

void accept(struct customer[], int);

void display(struct customer[], int);

int search(struct customer[], int, int);

void deposit(struct customer[], int, int, int);

void withdraw(struct customer[], int, int, int);

int main()

{

struct customer data[20];

int n, choice, account_no, amount, index;

printf("Banking System ");

printf("Number of customer records you want to enter? : ");

scanf("%d", &n);

accept(data, n);

do { printf(" Banking System Menu : ");

printf("Press 1 to display all records. ");

printf("Press 2 to search a record. ");

printf("Press 3 to deposit amount. ");

printf("Press 4 to withdraw amount. ");

printf("Press 0 to exit ");

printf(" Enter choice(0-4) : ");

scanf("%d", &choice);

switch (choice)

{

case 1: display(data, n); break;

case 2: printf("Enter account number to search : ");

scanf("%d", &account_no);

index = search(data, n, account_no);

if (index == - 1)

{

printf("Record not found : ");

}

else

{ printf("A/c Number: %d Name: %s Balance: %d ", data[index].account_no, data[index].name, data[index].balance);

}

break;

case 3: printf("Enter account number : ");

scanf("%d", &account_no);

printf("Enter amount to deposit : ");

scanf("%d", &amount);

deposit(data, n, account_no, amount);

break;

case 4: printf("Enter account number : ");

scanf("%d", &account_no);

printf("Enter amount to withdraw : ");

scanf("%d", &amount);

withdraw(data, n, account_no, amount);

}

}

while (choice != 0);

return 0;

}

void accept(struct customer list[80], int s)

{

int i;

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

{ printf(" Enter data for Record #%d", i + 1);

printf(" Enter account_no : ");

scanf("%d", &list[i].account_no);

fflush(stdin);

printf("Enter name : ");

gets(list[i].name);

list[i].balance = 0;

}

}

void display(struct customer list[80], int s)

{ int i;

printf(" A/c No\tName\tBalance ");

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

{ printf("%d\t%s\t%d ", list[i].account_no, list[i].name, list[i].balance);

}

}

int search(struct customer list[80], int s, int number)

{ int i;

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

{ if (list[i].account_no == number) { return i;

}

}

return - 1;

}

void deposit(struct customer list[], int s, int number, int amt)

{ int i = search(list, s, number);

if (i == - 1) { printf("Record not found");

}

else

{

list[i].balance += amt;

}

}

void withdraw(struct customer list[], int s, int number, int amt)

{ int i = search(list, s, number);

if (i == - 1)

{ printf("Record not found "); }

else if (list[i].balance < amt)

{ printf("Insufficient balance ");

}

else

{ list[i].balance -= amt; }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Multimedia Database Systems

Authors: V.S. Subrahmanian

1st Edition

1558604669, 978-1558604667

More Books

Students also viewed these Databases questions