Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need Help Completeing My Project Assignment. Please someone Help me add the following options to my Project1.cpp file and create a bank.h header file

I need Help Completeing My Project Assignment. Please someone Help me add the following options to my Project1.cpp file and create a bank.h header file and a bank.cpp file.

Add three more options to your main program:

o List all records in the increasing order of account number;

o List all the records in the increasing order of account balance;

o List all the transactions (there is no order requirement).

To implement the new options List all records in the increasing order of account number and List all the records in the increasing order of account balance, your main program needs to use the data structure and functions declared and defined in bank.h and bank.cpp that you create.

Your bank.h file should contain (1) the declaration of a data structure (say account), which is the node of a linked list used to store account information; and (2) at least three function declarations (two are used to insert a node into the linked list and one is used to show the contents in the linked list).

Your bank.cpp file should contain the definitions (implementations) of the functions declared in bank.h file.

To list the records in some order, first you should read all the accounts from the database: for each account, create a node (instance of data structure, say account) and insert it (in some order) into a linked list, and second you display the records in the linked list.

Project1.cpp

#include #include #include using namespace std; struct bank { int accNumber; string Fname, Lname; float balance; }; static int j = 0; struct bank B[5]; void read_from_file(const char* filename) { /*Variable declarations*/ ifstream infile; /*Opening file*/ infile.open (filename); int i=0; if (infile.is_open()) { /*Reading all details from file*/ while(!infile.eof()) // To get you all the lines. { infile>>B[i].accNumber; infile>>B[i].Fname; // Saves the line in STRING. infile>>B[i].Lname; infile>>B[i].balance; /*To prevent read last line twice*/ if( infile.eof() ) { break; } j++; i++; } /*Printing all account details after reading*/ for (i = 0; i> accNum; for (i = 0; i> B[i].Fname; cout << "last name: "; cin >> B[i].Lname; cout << "Balance:"; cin >> B[i].balance; } void deleteAccount() { int accNum; cout << "Enter account number: "; cin >> accNum; for (int i = 0; i> accNum; for (int i = 0; i> accNum; for (int i = 0; i> withd; if (B[i].balance >= withd){ B[i].balance = B[i].balance - withd; cout << "Total :" << B[i].balance << " "; return 0; } else{ cout << "Error: No changes should be made to the database "; return 0; } } else{ flag=1; } } if(flag==1){ cout << "Error: No changes should be made to the database "; return 0; } } int deposit() { float dep; int accNum,flag=0; cout << "Enter account number you want to Deposit:"; cin >> accNum; for (int i = 0; i> dep; B[i].balance = B[i].balance + dep; cout << "Total :" << B[i].balance << " "; return 0; } else{ flag=1; } } if(flag==1){ cout << "Error: No changes should be made to the database "; return 0; } } int transfer() { float tran; int fromAcc, toAcc, fr, to, i, f1, f2; cout << "Enter account number you want to transfer from "; cin >> fromAcc; cout << "to "; cin >> toAcc; for (i = 0; i> tran; if (B[fr].balance >= tran){ B[to].balance = B[to].balance + tran; B[fr].balance = B[fr].balance - tran; } else{ cout << "Error: No changes should be made to the database "; return 0; } } else{ cout << "Error: No changes should be made to the database "; return 0; } } void list() { for (int i = 0; i> op; switch (op){ case 1: addAccount(); break; case 2: deleteAccount(); break; case 3: searchAccount(); break; case 4: withdraw(); break; case 5: deposit(); break; case 6: transfer(); break; case 7: list(); break; default: cout << "Invalid operation "; exit(0); } cout << "Do you wants more operation (Y/y) by default No : "; cin >> ch; } while (ch == 'Y' || ch == 'y'); /*Writing into File at the End of all operations*/ write_into_file("account.txt"); }

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

=+ Are unions company-wide, regional, or national?

Answered: 1 week ago