Based on coding below, help me fix all the error until the program can be run properly and neatly #include #include #include #include using namespace std; struct nodeBankAccount { string bank_acc_name; string bank_acc_num; double bank_acc_bal;    nodeBankAccount*link; }; nodeBankAccount *head, *rear; nodeBankAccount *current; nodeBankAccount *newNode; nodeBankAccount *deleteBank; nodeBankAccount *previous; nodeBankAccount *found; void addBankAccount() { char answer; int insertOption;    do { newNode = new nodeBankAccount;    cout << "Fill in the details below" << endl; cout << "Bank Account Name: "; cin>>newNode->bank_acc_name; cout << "Bank Account Number: "; cin>>newNode->bank_acc_num; cout << "Bank Account Balance: " << "RM "; cin>>newNode->bank_acc_bal; newNode->link = NULL;    if(head == NULL) { head = newNode; }else{ cout<<"Press 1 to insert the new record at front of the list\n"; cout<<"Press 2 to insert the new record at rear of the list\n"; cout<< "Enter your choice [1 or 2]: "; cin>>insertOption; if(insertOption == 1) { newNode->link = head; head = newNode;    }else{ rear->link = newNode; rear = newNode; } } cout<<"\nOne recors has been added into the list ";       cout<<"\nAdd more record? Press Y for yes and N for no: "; cin>>answer; }while(toupper(answer) == 'Y'); } void viewBankAccount() { int no=1; int totalDetails = 0; int view; char answer2;    cout << "\nChoose view type" << endl; cout << "1 - List View" << endl; cout << "2 - Table View" << endl; cout << "\nEnter your choice: "; cin >> view;    switch (view) { case 1: current = head; while (current != NULL) { cout << "\n[Record " << no << "]" << endl; cout << "Bank account name: " << current->bank_acc_name << endl; cout << "Bank account number: " << current->bank_acc_num << endl; cout << "Bank account balance: " << current->bank_acc_bal << endl; no++; current = current->link; totalDetails++; } cout << "\nTotal number of user details: " << totalDetails << endl; break;    case 2: cout<bank_acc_name<bank_acc_num<bank_acc_bal<link; totalDetails++; } cout<<"-------------------------------------------------------------------------------------"<> answer2; } void deleteBankAccount() { int searchAccNum; char delete_answer; //delete operation do{ cout << "\n\nEnter account number to be deleted: "; cin >> searchAccNum;    current = head; previous = NULL; while(current != NULL) { if(strcmp(current->bank_acc_num, searchAccNum)==0) } deleteBank = current; if(head == rear) { head = NULL; rear = NULL; current = NULL; delete deleteBank; cout << "\n\nRecord has been deleted\n"; }else{ if(current == head) { rear = previous; rear ->link = NULL; current = NULL; delete deleteBank; cout << "\n\nRecord has been deleted\n"; }else{ //node to be deleted is the middle node previous->link = current ->link; current = NULL; delete deleteBank; cout <<"\n\nRecord has been deleted\n"; } } }       void searchBankAccount() { int searchAccNum;    found = NULL; current = head;    if(current == NULL) { cout<<"\n\n List is empty!!!\n\n"; }else{ cout<<"\nEnter bank account number to be searched: "; cin>>searchAccNum; while(current != NULL) { if(strcmp(current->bank_acc_num,searchAccNum)==0 ) { found = current; break; }else{ current = current->link; //move pointer current to the next node } } if(found == NULL) { cout<<"\n\nRecord does not exist!!!\n\n"; }else{ cout<bank_acc_name<bank_acc_num<bank_acc_bal<>menuOption;    switch(menuOption) { case 1: addBankAccount(); break;    /*case 2: searchBankAccount(); break;    case 3: deleteBankAccount(); break; */ case 4: viewBankAccount(); break;    case 5: cout<<"\n\n Program End\n\n"; break;    default: cout<<"Wrong option. Please reenter your option\n"; } }while(menuOption != 5);    return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Based on coding below, help me fix all the error until the program can be run properly and neatly

#include <iostream>
#include <iomanip>
#include <ctype.h>
#include <string>

using namespace std;

struct nodeBankAccount
{
string bank_acc_name;
string bank_acc_num;
double bank_acc_bal;
  
nodeBankAccount*link;
};

nodeBankAccount *head, *rear;
nodeBankAccount *current;
nodeBankAccount *newNode;
nodeBankAccount *deleteBank;
nodeBankAccount *previous;
nodeBankAccount *found;

void addBankAccount()
{
char answer;
int insertOption;
  
do
{
newNode = new nodeBankAccount;
  
cout << "Fill in the details below" << endl;
cout << "Bank Account Name: ";
cin>>newNode->bank_acc_name;
cout << "Bank Account Number: ";
cin>>newNode->bank_acc_num;
cout << "Bank Account Balance: " << "RM ";
cin>>newNode->bank_acc_bal;
newNode->link = NULL;
  
if(head == NULL)
{
head = newNode;
}else{
cout<<"Press 1 to insert the new record at front of the list\n";
cout<<"Press 2 to insert the new record at rear of the list\n";
cout<< "Enter your choice [1 or 2]: ";
cin>>insertOption;
if(insertOption == 1)
{
newNode->link = head;
head = newNode;
  
}else{
rear->link = newNode;
rear = newNode;
}
}
cout<<"\nOne recors has been added into the list ";
  
  
cout<<"\nAdd more record? Press Y for yes and N for no: ";
cin>>answer;
}while(toupper(answer) == 'Y');
}

void viewBankAccount()
{
int no=1;
int totalDetails = 0;
int view;
char answer2;
  
cout << "\nChoose view type" << endl;
cout << "1 - List View" << endl;
cout << "2 - Table View" << endl;
cout << "\nEnter your choice: ";
cin >> view;
  
switch (view)
{
case 1:
current = head;
while (current != NULL)
{
cout << "\n[Record " << no << "]" << endl;
cout << "Bank account name: " << current->bank_acc_name << endl;
cout << "Bank account number: " << current->bank_acc_num << endl;
cout << "Bank account balance: " << current->bank_acc_bal << endl;
no++;
current = current->link;
totalDetails++;
}
cout << "\nTotal number of user details: " << totalDetails << endl;
break;
  
case 2:
cout<<endl<<left<<setw(5)<<"No"<<setw(30)<<"Bank account name"<<setw(5)<<"Bank account number"<<setw(30)<<"Bank account balance"<<endl;
cout<<"-------------------------------------------------------------------------------------"<<endl;
current = head;
while(current != NULL)
{
cout<<left<<setw(5)<<no<<setw(30)<<current->bank_acc_name<<setw(5)<<current->bank_acc_num<<current->bank_acc_bal<<endl;
no++;
current = current->link;
totalDetails++;
}
cout<<"-------------------------------------------------------------------------------------"<<endl;
cout<<"\n Total number of user details: "<<totalDetails<<endl;
break;

default: cout << "Wrong input. Please reenter the view option\n";
}

cout << "\nPress Y to go back to MAIN MENU: ";
cin >> answer2;
}
void deleteBankAccount()
{
int searchAccNum;
char delete_answer;
//delete operation
do{
cout << "\n\nEnter account number to be deleted: ";
cin >> searchAccNum;
  
current = head;
previous = NULL;
while(current != NULL)
{
if(strcmp(current->bank_acc_num, searchAccNum)==0)
}
deleteBank = current;
if(head == rear)
{
head = NULL;
rear = NULL;
current = NULL;
delete deleteBank;
cout << "\n\nRecord has been deleted\n";
}else{
if(current == head)
{
rear = previous;
rear ->link = NULL;
current = NULL;
delete deleteBank;
cout << "\n\nRecord has been deleted\n";
}else{ //node to be deleted is the middle node
previous->link = current ->link;
current = NULL;
delete deleteBank;
cout <<"\n\nRecord has been deleted\n";
}
}
}
  
  
void searchBankAccount()
{
int searchAccNum;
  
found = NULL;
current = head;
  
if(current == NULL)
{
cout<<"\n\n List is empty!!!\n\n";
}else{
cout<<"\nEnter bank account number to be searched: ";
cin>>searchAccNum;
while(current != NULL)
{
if(strcmp(current->bank_acc_num,searchAccNum)==0 )
{
found = current;
break;
}else{
current = current->link; //move pointer current to the next node
}
}
if(found == NULL)
{
cout<<"\n\nRecord does not exist!!!\n\n";
}else{
cout<<left<<setw(30)<<current->bank_acc_name<<setw(5)<<current->bank_acc_num<<current->bank_acc_bal<<endl;
}
  
}
}
  
}

int main()
{
int menuOption;
char answer;
  
head = NULL; //create list
  
do
{
cout<<"\n\n\tBank Account Information\n";
cout<<"--------------------------------------\n";
cout<<"\t\tMain Menu\n";
cout<<"--------------------------------------\n";
cout<<"1 - Add Bank Account Details\n";
cout<<"2 - Search Bank Account Details\n";
cout<<"3 - Delete bank account details\n";
cout<<"4 - View details\n";
cout<<"5 - Exit\n";
cout<<"---------------------------------------\n";
  
cout<<"Enter your option [1, 2, 3, 4 or 5]: ";
cin>>menuOption;
  
switch(menuOption)
{
case 1: addBankAccount();
break;
  
/*case 2: searchBankAccount();
break;
  
case 3: deleteBankAccount();
break;
*/
case 4: viewBankAccount();
break;
  
case 5: cout<<"\n\n Program End\n\n";
break;
  
default: cout<<"Wrong option. Please reenter your option\n";
}
}while(menuOption != 5);
  
return 0;
}

Expert Solution
steps

Step by step

Solved in 2 steps with 11 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education