Question: -modify the code below -create a menu with functions that modify current code -Add function has to check for valid phone number input, date inputted

-modify the code below
-create a menu with functions that modify current code
-Add function has to check for valid phone number input, date inputted cannot be a date that has not already happened
-verify account number
#include
#include
#include
#include
#include
#include
using namespace std;
//create a node struct
struct Node
{
int act_number;
string last_name;
string first_name;
char middle_initial;
unsigned int year;
unsigned int month;
unsigned int day;
float annual_salary;
char dept_code;
string phone_number;
struct Node *left;
struct Node *right;
};
typedef struct Node node;
//create a binary insert
void binaryInsert(node *temp,node *head)
{
//set temp equal to head
node *tmp = head;
while(1)
{
//if the first pointer is greater than the second pointer
if(tmp->act_number > temp->act_number)
{
//if the pointer to the left child is not equal to NULL
if(tmp->left != NULL)
{
//set tmp equal to tmp point left
tmp = tmp->left;
}
else
{
//temp point left is equal to temp
tmp->left = temp;
break;
}
}
else
{
//if tmp point right child is not equal to NULL
if(tmp->right != NULL)
{
//tmp is equal to tmp point right
tmp = tmp->right;
}
else
{
//tmp point right child is equal to temp
tmp->right = temp;
break;
}
}
}
}
//create a function that reads in the input from a file
node* insert(ifstream &file, vector & QV)
{
//set head equal to NULL
node *head = NULL;
//while not at the end of the file
while(!file.eof())
{
//set temp equal to new node
node *temp = new node;
//read in the information
file>>temp->act_number>>temp->first_name>>temp->middle_initial>>temp->last_name>>temp->month>>temp->day;
if(file.eof())
{
break;
}
//read in information
file>>temp->year>>temp->annual_salary>>temp->dept_code>>temp->phone_number;
//make the department code uppercase
temp->dept_code = toupper(temp->first_name[0]);
//make the first initial of first name uppercase
temp->first_name[0] = toupper(temp->first_name[0]);
//resize the vector
QV.resize (QV.size()+1);
//put all information that is read in, into the vector
QV[QV.size()-1]= temp;
temp->right = NULL;
temp->left = NULL;
if(head == NULL)
{
head = temp;
}
else
{
//call the Binaryinsert function
binaryInsert(temp,head);
}
}
return head;
}
//create an array for the months
string month[12]={"Jan.","Feb.","Mar.","Apr.","May","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."};
//create a print function that prints out the entities from the struct
void printReport(node *temp,ostream & out)
{
out
outact_numberlast_namefirst_namemonth -1]day;
outyearannual_salarydept_code;
}
//create a print function for the salary
void printSalary(vector QV, ostream & out)
{
float totalsal = 0;
out
out
out
//create a for loop that creates a salary report
for (int i =0; i
{
outlast_namefirst_name[0]annual_salaryphone_number;
outdept_code
totalsal += QV[i]->annual_salary;
}
//accumulate the total salary and print
out
}
//create a function that arranges the information in order
void printInorder(node *temp, ofstream & outf)
{
if(temp == NULL)
{
return;
}
else
{
printInorder(temp->left,outf);
printReport(temp,outf);
printInorder(temp->right,outf);
}
}
//create a function that arranges the information in preorder
void printPreOrder(node *temp,ofstream & outf)
{
if(temp == NULL)
{
return;
}
else
{
printReport(temp,outf);
printPreOrder(temp->left,outf);
printPreOrder(temp->right,outf);
}
}
//create a function that arranges the information in post order
void printPostOrder(node *temp,ofstream & outf)
{
// if temp is null, return
if(temp == NULL)
{
return;
}
else
{
printPostOrder(temp->left,outf);
printPostOrder(temp->right,outf);
printReport(temp,outf);
}
}
//create a swap function for the QuickSort
void SwapFunc (node *& s1, node *& s2)
{
node * temp = s1;
s1 = s2;
s2 = temp;
}
//create a quicksort for the salary report
void QuickSort(vector & QV, int Lower, int Upper)
{
//declare variables that are going to be needed
int Lo = Lower;
int Hi = Upper;
//set the pivot of the sort equal to (Hi+Lo)/2 that is pointing to the lastname
string pvt = QV.at((Hi+Lo)/2)->last_name;
while (Lo
{
//while the position of Lo that is pointing to the last name is less than the pivot
while(QV.at(Lo)->last_name
//increment Lo
Lo++;
//while the position of Hi that is pointing to the lastname is greater than the pivot
while (QV.at(Hi)->last_name > pvt)
//decrement the Hi
Hi--;
//if Lo is less than or equal to Hi
if (Lo
{
//call the swap function
SwapFunc(QV.at(Lo), QV.at(Hi));
//increment Lo and decrement Hi
Lo++;
Hi--;
}
}
//if Lower is less than Hi, call the Quicksort with those parameters
if (Lower
QuickSort(QV, Lower, Hi);
//if Lo is less than Upper , call the Quicksort with those parameters
if (Lo
QuickSort(QV, Lo, Upper);
}
//create a print all function that is used for inorder, preorder, and postorder
void printAll(node *head, ofstream & out, ofstream & out2, ofstream & out3, int count)
{
out
out
printInorder(head,out);
out
out2
out2
printPreOrder(head,out2);
out2
out3
out3
printPostOrder(head,out3);
out3
}
//main
int main()
{
//initialize variables
vector QV(0);
ifstream file;
string fname;
//create output files
ofstream out;
out.open ("InOrder.txt");
ofstream out2;
out2.open ("Preorder.txt");
ofstream out3;
out3.open ("Postorder.txt");
ofstream out4;
out4.open("SalaryReport.txt");
node *head;
cout
cin>>fname;
file.open(fname.c_str());
//open file
if(file.is_open())
{
//set head equal to the insert function
head = insert(file,QV);
file.close();
//call the QuickSort function
QuickSort(QV,0,QV.size()-1);
//call the print salary function
printSalary(QV,out4);
//call the printall function
printAll(head, out, out2, out3,QV.size());
}
//the user entered the wrong filename
else
{
cout
return -1;
}
}
 -modify the code below -create a menu with functions that modify
current code -Add function has to check for valid phone number input,
BST UPDATE PROJECT Add the following functions to the BST Create program you have already developed. Implement a menu to allow the user to select the desired function. The program will create a BST using the data stored on the MASTER input file when it is launched. The program must display the following MENU: BST UPDATE SYSTEM A) To Add an new record M) To MODIFY a record P) To print a report in order S) Save Changes (write current BST to MASTER FILE) Q) Quit [Exit System] Implementation guide lines Option k: prompt for the account number of the record to be added to the BST. If the record already exist DISPLAY DUPLICATES ARE NOT ALLOWED Re-display menu If the record is not found, prompt for the remaining fields (one at a time) and insert the new record into the BST (validate the month, day and year and phone number) Option M: Prompt the user for the account number of the record to be modified, if the record is present DISPLAY " RECORD 999 is NOT FOUND" re-display the menu if the record is present prompt the user for the remaining fields(validate the month, day and year and phone number) (one at a time) modify

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!