Grading Log for CS113 -- HW5 Name: Lonh, Borin SCRIPT FILES ====== ===== h5.scr =================================================== > Script started on Wed Apr 14 18:47:28 1999 > %cat h5acct.c > /* > * File Name: h5acct.c > * Name: Borin Lonh > * Assignment: 5 > * Problem: 1 > * Date: Apr 13, 1999 > * > * This program utilizes a binary search tree to build and maintain > * a small account database. The account numbers will serve as the > * search keys for the binary search tree. Data will initially be > * read from a file, and the user will be prompted with options > * regarding what to do with the accounts. > */ > > #include > #include > #include "h5tree.h" > > #define FNAME_MAX 50 /* maximum filename length */ > > /* > * TYPE DEFINITIONS > */ > typedef treeElementT accountT; > typedef treeKeyT acctNumT; > > /* > * FUNCTION PROTOTYPES > */ > void PrintAccountMainMenu(void); > void AccountReadFromFile(treeADT tree); > void AccountAdd(treeADT tree); > void AccountDelete(treeADT tree); > void AccountFind(treeADT tree); > void AccountPrint(treeADT tree); > > /* > * BEGIN MAIN PROGRAM > */ > int main(void) > { > treeADT tree; /* tree holding the account information */ > > char choice[2]; /* main menu choice */ > > /* create a tree to hold the accounts */ > tree = TreeCreate(); > > AccountReadFromFile(tree); /* read account info from file */ > PrintAccountMainMenu(); /* print main menu */ > printf("Choice> "); > scanf("%s", choice); > > while (choice[0] != 'q') > { > switch (choice[0]) > { > case 'a': > AccountAdd(tree); > break; > case 'd': > AccountDelete(tree); > break; > case 'f': > AccountFind(tree); > break; > case 'p': > AccountPrint(tree); > break; > default: > printf("Error!! Invalid Selection.\n"); > break; > } > > printf("\nChoice> "); /* prompts for next selection */ > scanf("%s", choice); /* scans in choice */ > } > > printf("Bye! Thanks for using account.\n"); /* Goodbye message */ > > TreeDestroy(tree); > > return 0; > } > /* > * END MAIN PROGRAM > */ > > /* > * Function: PrintAccountMainMenu > * Usage: PrintAccountMainMenu(); > * ------------------------------ > * This procedure prints out the main menu options. > */ > void PrintAccountMainMenu(void) > { > printf("Please choose one of the following operations by typing its\n"); > printf("letter and then pressing :\n\n"); > printf(" a) Add an account to the database.\n"); > printf(" d) Delete an account from the database.\n"); > printf(" f) Find an account in the database.\n"); > printf(" p) Print account database.\n"); > printf(" q) Quit inventory.\n\n"); > } > > /* > * Function: AccountReadFromFile > * Usage: AccountReadFromFile(tree); > * --------------------------------- > * This procedure reads in an account data file and adds > * the account data to a binary search tree. > */ > void AccountReadFromFile(treeADT tree) > { > accountT account; /* account information */ > > /* name of account data file to be opened */ > char filename[FNAME_MAX+1] = "/cs/course/cs113/current/hw5/accounts.in"; > > FILE *ifp; /* input file pointer */ > > printf("Initial account data read from file:\n"); > printf("\"%s\"\n\n",filename); > > /* attempt to open account data file for reading */ > ifp = fopen(filename, "r"); > > /* print error message if unable to open data file */ > if (ifp == NULL) > { > printf("Error!! Unable to open account database file.\n"); > exit(1); /* exit, returning error code */ > } > else > { > /* if file successfully opened, loop to read in account data */ > while (fscanf(ifp,"%d %s %d", &account.key, account.value.name, &account.value.balance) == 3) > TreeAdd(tree,account); /* add accounts to tree */ > > fclose(ifp); /* close input file */ > } > } > > /* > * Function: AccountAdd > * Usage: AccountAdd(tree); > * ------------------------ > * This procedure prompts a user for an account number, name, and balance > * and adds the account information to the binary search tree. > */ > void AccountAdd(treeADT tree) > { > accountT account; /* account information */ > > printf("Please enter the account number: "); > while (scanf("%d",&account.key) == 0 || (account.key < 1) || (account.key > 100000)) > { > printf("Error!! Account number is invalid.\n"); > printf("Account number must be an integer between 1 and 100000.\n"); > printf("Please enter the account number: "); > } > > printf("Please enter the account owner's name: "); > scanf("%s",account.value.name); > > printf("Please enter the account balance: "); > while (scanf("%d",&account.value.balance) == 0) > { > printf("Error!! Account balance is invalid.\n"); > printf("Account balance must be an integer.\n"); > printf("Please enter the account balance: "); > } > > TreeAdd(tree,account); /* add account to tree */ > } > > /* > * Function: AccountDelete > * Usage: AccountDelete(tree); > * --------------------------- > * This procedure prompts the user for an account number. It then > * searches for the account number in the tree. If it is found, it > * will remove the account information from the tree and print it. > * If not, it will just print an error message. > */ > void AccountDelete(treeADT tree) > { > acctNumT acct_num; /* account number */ > accountT account, /* account information */ > *acctP; /* pointer to an account */ > > printf("Enter the number of the account to be deleted: "); > while (scanf("%d",&acct_num) == 0 || (acct_num < 1) || (acct_num > 100000)) > { > printf("Error!! Account number is invalid.\n"); > printf("Account number must be an integer between 1 and 100000.\n"); > printf("Enter the number of the account to be deleted: "); > } > > /* check if account exists in tree */ > acctP = TreeFind(tree,acct_num); > > /* if account doesn't exist, print an error message */ > if (acctP == NULL) > printf("Error!! Account number \"%d\" does not exist in database.\n", acct_num); > else > { > /* if account exists, delete it from the tree and print its information */ > account = TreeDelete(tree,acct_num); /* delete account from tree */ > printf("The following account information was deleted:\n"); > PrintElement(account,stdout); > } > } > > /* > * Function: AccountFind > * Usage: AccountFind(tree); > * ------------------------- > * This procedure prompts the user for an account number and > * attempts to find it in the tree. If it is found, it will > * print out the account information. If not, it will just > * print an error message. > */ > void AccountFind(treeADT tree) > { > acctNumT acct_num; /* account number */ > accountT *accountP; /* pointer to an account */ > > printf("Enter the number of the account to be found: "); > while (scanf("%d",&acct_num) == 0 || (acct_num < 1) || (acct_num > 100000)) > { > printf("Error!! Account number is invalid.\n"); > printf("Account number must be an integer between 1 and 100000.\n"); > printf("Enter the number of the account to be found: "); > } > > /* check if account exists in tree */ > accountP = TreeFind(tree,acct_num); > > if (accountP == NULL) > printf("Error!! Account number \"%d\" not found.\n", acct_num); > else > PrintElement(*accountP,stdout); > } > > /* > * Function: AccountPrint > * Usage: AccountPrint(tree); > * -------------------------- > * This procedure prompts the user whether to print the account > * database to the screen or to a file and then prints out each > * account information using preorder traversal of the tree. > */ > void AccountPrint(treeADT tree) > { > char choice[5]; /* string holding user's choice */ > > FILE *ofp; /* output file pointer */ > > printf("Please choose where the account information should\n"); > printf("be printed and hit :\n\n"); > printf(" s) Print to screen\n"); > printf(" f) Print to file \"accounts.out\"\n"); > printf(" r) Return to Main Menu prompt.\n\n"); > printf("Print Choice> "); > scanf("%s",choice); > > while (choice[0] != 'r') > { > switch (choice[0]) > { > case 's': > TreePrint(tree,stdout); /* print to the screen */ > return; /* exit function */ > case 'f': > ofp = fopen("accounts.out", "w"); /* attempt to open file for writing */ > TreePrint(tree,ofp); /* print out tree elements to file */ > fclose(ofp); /* close output file */ > return; /* exit function */ > default: > printf("Invalid selection.\n"); > break; > } > printf("\nPrint Choice> "); > scanf("%s",choice); > } > } /* * Printing to "accounts.out" should have been done automatically * as last thing program does. --TF */ > > /* > * Function: PrintElement > * ---------------------- > * This procedure prints out the elements of the tree. > */ > void PrintElement(accountT account, FILE *outfileP) > { > fprintf(outfileP,"Account Number: %d\n", account.key); > fprintf(outfileP,"Account Name: %s\n", account.value.name); > fprintf(outfileP,"Account Balance: %d\n\n", account.value.balance); > } > %cat h5tree.h > /* > * File Name: h5tree.h > * Name: Borin Lonh > * Assignment: 5 > * Problem: 1 > * Date: Apr 13, 1999 > * > * This is the interface file for the tree module. It > * includes the constants, types, and function prototypes. > * Documentation on how the function prototypes should be > * used by a main program are included. > */ > > /* begin header file "wrap" */ > #ifndef _h5tree_h > #define _h5tree_h > > #define MAX_NAME 30 /* maximum name length */ > > typedef int treeKeyT; > > /* tree value data structure */ > typedef struct { > char name[MAX_NAME+1]; /* one extra for null character */ > int balance; /* the account balance */ > } treeValueT; > > /* tree element data structure */ > typedef struct { > treeKeyT key; > treeValueT value; > } treeElementT; > > typedef struct treeCDT *treeADT; > > /* > * Function: TreeCreate > * Usage: tree = TreeCreate(); > * --------------------------- > * This procedure creates and initializes the root tree node. > */ > treeADT TreeCreate(void); > > /* > * Function: TreeDestroy > * Usage: TreeDestroy(tree); > * ------------------------- > * This procedure deallocates the memory used up by a tree. > */ > void TreeDestroy(treeADT tree); > > /* > * Function: TreeAdd > * Usage: TreeAdd(tree,element); > * ----------------------------- > * This procedure adds an element to the tree. > */ > void TreeAdd(treeADT tree, treeElementT element); > > /* > * Function: TreeDelete > * Usage: element = TreeDelete(tree,key); > * ---------------------------- > * This procedure deletes an element from a tree and returns it. > */ > treeElementT TreeDelete(treeADT tree, treeKeyT key); > > /* > * Function: TreeFind > * Usage: found = TreeFind(tree,key); > * ---------------------------------- > * This procedure attempts to find an element in the tree > * with a corresponding key. If found, it returns a pointer > * to that element. If not, it returns NULL. > */ > treeElementT *TreeFind(treeADT tree, treeKeyT key); > > /* > * Function: TreePrint > * Usage: TreePrint(tree,outfileP); > * -------------------------------- > * This procedure prints out the elements of a tree > * using preorder traversal. > */ > void TreePrint(treeADT tree, FILE *outfileP); > > /* > * Function: PrintElement > * Usage: PrintElement(element,outfileP); > * -------------------------------------- > * PrintElement is not defined here in the tree module, it is > * only prototyped here. It must be defined in the main program > * to be used by TreePrint in the implementation module. > */ > void PrintElement(treeElementT element, FILE *outfileP); > > /* end header file "wrap" */ > #endif > %cat h5tree.c > /* > * File Name: h5tree.c > * Name: Borin Lonh > * Assignment: 5 > * Problem: 1 > * Date: Apr 13, 1999 > * > * This is the implementation file for the tree module. It > * contains the functions needed to perform tree operations. > */ > > #include > #include > #include "h5tree.h" > > /* tree node data structure */ > typedef struct treeNodeTag { > treeElementT element; /* tree element */ > struct treeNodeTag *left; /* left tree link */ > struct treeNodeTag *right; /* right tree link */ > } treeNodeT; > > /* treeCDT data structure */ > typedef struct treeCDT { > treeNodeT *root; > } treeCDT; > > /* > * HELPER FUNCTION PROTOTYPES > */ > static void RecTreePrint(treeNodeT *root, FILE *outfileP); > static void RecTreeDestroy(treeNodeT *root); > static treeNodeT *FindCurrentNode(treeADT tree, treeKeyT key); > static treeNodeT *FindParentNode(treeADT tree, treeKeyT key); > static treeNodeT *FindMaxNode(treeNodeT *root); > > /* > * Function: TreeCreate > * -------------------- > * This procedure initializes an empty tree by setting > * the pointer to the root of the tree equal to NULL. > */ > treeADT TreeCreate(void) > { > treeADT tree; /* pointer to a treeCDT */ > > tree = (treeADT)malloc(sizeof(treeCDT)); > > /* if allocation fails, print an error message and exit */ > if (tree == NULL) > { > fprintf(stderr,"Insufficient memory for new tree.\n"); > exit(1); /* exit, returning error code. */ > } > > tree->root = NULL; /* initialize root pointer of the tree */ > return tree; > } > > /* > * Function: TreeDestroy > * --------------------- > * This procedure calls a recursive function to free the memory > * used up by the tree nodes and resets the root pointer of the > * tree to NULL. > */ > void TreeDestroy(treeADT tree) > { > RecTreeDestroy(tree->root); /* start at root of tree */ > tree->root = NULL; /* reset root pointer to NULL */ > > /* free structure which holds information about tree */ > free(tree); > } > > /* > * Function: RecTreeDestroy > * ------------------------ > * This procedure uses a postorder traversal of the tree > * and recursively calls itself to free the tree nodes in > * a postorder manner so that links to other nodes are not > * lost if the root is deleted. > */ > static void RecTreeDestroy(treeNodeT *root) > { > if (root == NULL) /* base case to stop recursing */ > return; > else > { > RecTreeDestroy(root->left); /* traverse left */ > RecTreeDestroy(root->right); /* traverse right */ > free(root); /* deallocate memory */ > } > } > > /* > * Function: TreeAdd > * ----------------- > * This procedure adds a new node to a tree to the > * bottom of the tree. If the element is already in > * the tree, it just adds the element. > */ > void TreeAdd(treeADT tree, treeElementT element) > { > treeNodeT *new_tree_node, /* new tree node */ > *currentP, /* pointer to the current tree node */ > *parentP; /* pointer to parent of current node */ > > /* check to see if element's key is already in the tree */ > currentP = FindCurrentNode(tree,element.key); > > /* if element's key is already in the tree, just */ > /* add the new element and exit the function */ > if (currentP != NULL) > { > currentP->element = element; > return; /* exit the function */ > } > > /* if the element's key is not already in the tree, search for */ > /* an empty branch onto which the new leaf node will be added */ > > parentP = NULL; > currentP = tree->root; /* start at root of tree */ > > /* search for empty branch to add an element */ > while (currentP != NULL) > { > parentP = currentP; > if (element.key == currentP->element.key) > break; > else if (element.key < currentP->element.key) > currentP = currentP->left; > else if (element.key > currentP->element.key) > currentP = currentP->right; > } > > /* attempt to allocate space in memory for a new tree node */ > new_tree_node = (treeNodeT *) malloc(sizeof(treeNodeT)); > > /* print error message if allocation fails */ > if (new_tree_node == NULL) > { > fprintf(stderr,"Insufficient memory to add a new tree node.\n"); > TreeDestroy(tree); > exit(1); > } > else > { > /* add the element to the new tree node */ > new_tree_node->element = element; > new_tree_node->left = NULL; > new_tree_node->right = NULL; > > /* connect the new tree node with the rest of the tree */ > /* depending on whether or not it is the root or it is */ > /* less than or greater than the root */ > if (parentP == NULL) > tree->root = new_tree_node; > else if (new_tree_node->element.key < parentP->element.key) > parentP->left = new_tree_node; > else if (new_tree_node->element.key > parentP->element.key) > parentP->right = new_tree_node; > } > } > > /* > * Function: TreeDelete > * -------------------- > * This procedure deletes an element from a tree, depending > * on whether the element is a leaf, has only one connecting > * branch, or is a root node. > */ > treeElementT TreeDelete(treeADT tree, treeKeyT key) > { > treeNodeT *currentP, /* pointer to node to be deleted */ > *parentP, /* pointer to parent of node to be deleted */ > *max_nodeP, /* pointer to node with largest key */ > *max_node_parP; /* pointer to parent of node with largest key */ > > treeElementT deleted; /* element that is deleted from the tree */ > > if (tree->root == NULL) > { > printf("Error!! There are no tree nodes to be deleted.\n"); > TreeDestroy(tree); /* deallocate memory used by tree */ > exit(1); /* exit program, returning error code */ > } > else > { > /* find the node to be deleted */ > currentP = FindCurrentNode(tree,key); > if (currentP == NULL) > { > printf("Error!! The key to be deleted does not exist in the tree.\n"); > TreeDestroy(tree); /* deallocate memory used by tree */ > exit(1); /* exit program, returning error code */ > } > else > { > /* if the node exists, find it's parent node */ > parentP = FindParentNode(tree,key); > > /* copy deleted node's element into a variable to return */ > deleted = currentP->element; > > /* case for deletion if node is a leaf */ > if ((currentP->left == NULL) && (currentP->right == NULL)) > { > /* set left and right pointers of parent node to NULL */ > if (parentP->left == currentP) > parentP->left = NULL; > else if (parentP->right == currentP) > parentP->right = NULL; > } > /* case for deletion if node has a left branch and no right branch */ > else if ((currentP->left != NULL) && (currentP->right == NULL)) > { > if (parentP->left == currentP) > parentP->left = currentP->left; > else if (parentP->right == currentP) > parentP->right = currentP->left; > } > /* case for deletion if node has a right branch and no left branch */ > else if ((currentP->right != NULL) && (currentP->left == NULL)) > { > if (parentP->left == currentP) > parentP->left = currentP->right; > else if (parentP->right == currentP) > parentP->right = currentP->right; > } > /* case for deletion if node has two branches */ > else if ((currentP->left != NULL) && (currentP->right != NULL)) > { > /* this type of deletion involves finding the largest key node in the */ > /* left subtree and basically swaps the element of the largest node */ > /* with the node to be deleted, relinks the tree, and frees the max node */ > > /* find largest key node and its parent in left subtree */ > max_nodeP = FindMaxNode(currentP->left); > max_node_parP = FindParentNode(tree,max_nodeP->element.key); > > /* if maximum key node is a leaf and it's parent is not equal */ > /* to current, then set the left and right pointers of the parent */ > /* to NULL, else just have the parent's left pointer point to NULL */ > /* so that the right subtree of the deleted node is not lost. */ /* The deletion code below is not quite right. --TF */ > if ((max_nodeP->left == NULL) && (max_nodeP->right == NULL)) > { > if (max_node_parP != currentP) > { > max_node_parP->left = NULL; > max_node_parP->right = NULL; > } > else > max_node_parP->left = NULL; > } > else > max_node_parP->right = max_nodeP->left; > > /* swap max node element into deleted node */ > currentP->element = max_nodeP->element; > /* have current point to max to free the maximum key node */ > currentP = max_nodeP; > } > } > } > free(currentP); /* deallocate memory of current node */ > return deleted; > } > > /* > * Function: TreeFind > * ------------------ > * This procedure takes in a key and searches the tree for an > * element with that key. If it finds an element with the key, > * it returns a pointer to that element. If not, the function > * will return NULL. > */ > treeElementT *TreeFind(treeADT tree, treeKeyT key) > { > treeNodeT *currentP; /* pointer to the current tree node */ > > currentP = tree->root; /* set current to the root of the tree */ > > /* search for the key */ > while (currentP != NULL) > { > if (key == currentP->element.key) > return ¤tP->element; /* return pointer to element if key's match */ > /* move current left or right if keys don't match */ > else if (key < currentP->element.key) > currentP = currentP->left; > else if (key > currentP->element.key) > currentP = currentP->right; > } > return NULL; > } > > /* > * Function: TreePrint > * ------------------- > * This procedure checks if the tree is empty. If empty, an > * error message is printed, otherwise RecTreePrint is called > * to print the elements of the tree in preorder. > */ > void TreePrint(treeADT tree, FILE *outfileP) > { > if (tree->root == NULL) > printf("Error!! There are no elements in the tree to be printed.\n\n"); /* ^^ Not an error condition -- TF */ > else > RecTreePrint(tree->root,outfileP); > } > > /* > * Function: RecTreePrint > * ---------------------- > * This procedure is a recursive function which prints out > * elements of a tree in preorder. > */ > static void RecTreePrint(treeNodeT *root, FILE *outfileP) > { > if (root == NULL) /* base case to stop recursing */ > return; > else > { > PrintElement(root->element,outfileP); /* print root element */ > RecTreePrint(root->left,outfileP); /* traverse left node */ > RecTreePrint(root->right,outfileP); /* traverse right node */ > } > } > > /* > * Function: FindCurrentNode > * ------------------------- > * This is a helper function which returns > * a pointer to a key's node. > */ > static treeNodeT *FindCurrentNode(treeADT tree, treeKeyT key) > { > treeNodeT *currentP; /* pointer to the current tree node */ > > currentP = tree->root; /* set current to the root node of the tree */ > > while (currentP != NULL) > { > if (key == currentP->element.key) > return currentP; > /* move current left or right accordingly */ > else if (key < currentP->element.key) > currentP = currentP->left; > else if (key > currentP->element.key) > currentP = currentP->right; > } > return NULL; > } > > /* > * Function: FindParentNode > * ------------------------ > * This is a helper function which returns > * a pointer to the parent of a key's node. > */ > static treeNodeT *FindParentNode(treeADT tree, treeKeyT key) > { > treeNodeT *currentP, /* pointer to the current tree node */ > *parentP; /* pointer to the parent of the current node */ > > parentP = NULL; > currentP = tree->root; /* set current to the root node of the tree */ > > while (currentP != NULL) > { > if (key == currentP->element.key) > return parentP; > /* increment parent and current pointers accordingly */ > else if (key < currentP->element.key) > { > parentP = currentP; > currentP = currentP->left; > } > else if (key > currentP->element.key) > { > parentP = currentP; > currentP = currentP->right; > } > } > return NULL; > } > > /* > * Function: FindMaxNode > * --------------------- > * This is a helper function which returns a > * pointer to the largest key node in a tree. > */ > static treeNodeT *FindMaxNode(treeNodeT *root) > { > if (root != NULL) > while (root->right != NULL) > root = root->right; > > return root; > } > %make -f h5makefile > gcc -ansi -pedantic -Wall -g -c h5acct.c > gcc -ansi -pedantic -Wall -g -c h5tree.c > gcc -ansi -pedantic -Wall -g -o h5acct h5acct.o h5tree.o > %h5acct > Initial account data read from file: > "/cs/course/cs113/current/hw5/accounts.in" > > Please choose one of the following operations by typing its > letter and then pressing : > > a) Add an account to the database. > d) Delete an account from the database. > f) Find an account in the database. > p) Print account database. > q) Quit inventory. > > Choice> p > Please choose where the account information should > be printed and hit : > > s) Print to screen > f) Print to file "accounts.out" > r) Return to Main Menu prompt. > > Print Choice> s > Account Number: 46783 > Account Name: Pezzoli > Account Balance: 845 > > Account Number: 2984 > Account Name: Rubenstein > Account Balance: 232 > > Account Number: 945 > Account Name: Battle > Account Balance: 67 > > Account Number: 19845 > Account Name: Martin > Account Balance: 0 > > Account Number: 11935 > Account Name: Mutter > Account Balance: 666 > > Account Number: 11972 > Account Name: Cleese > Account Balance: 1962 > > Account Number: 44092 > Account Name: Selman > Account Balance: 98 > > Account Number: 20638 > Account Name: Yorra > Account Balance: 5621 > > Account Number: 64938 > Account Name: Slaman > Account Balance: 1111 > > Account Number: 98334 > Account Name: Evans > Account Balance: 2387 > > Account Number: 93221 > Account Name: Cedar > Account Balance: 520 > > Account Number: 73184 > Account Name: Standish > Account Balance: 25 > > Account Number: 88336 > Account Name: Buron > Account Balance: 45 > > > Choice> a > Please enter the account number: 50000 > Please enter the account owner's name: Borin > Please enter the account balance: 5746 > > Choice> a > Please enter the account number: -89 > Error!! Account number is invalid. > Account number must be an integer between 1 and 100000. > Please enter the account number: 1540 > Please enter the account owner's name: Mary > Please enter the account balance: 398 > > Choice> d > Enter the number of the account to be deleted: 88336 > The following account information was deleted: > Account Number: 88336 > Account Name: Buron > Account Balance: 45 > > > Choice> d > Enter the number of the account to be deleted: -679 > Error!! Account number is invalid. > Account number must be an integer between 1 and 100000. > Enter the number of the account to be deleted: 5000 > Error!! Account number "5000" does not exist in database. > > Choice> d > Enter the number of the account to be deleted: 64938 > The following account information was deleted: > Account Number: 64938 > Account Name: Slaman > Account Balance: 1111 > > > Choice> f > Enter the number of the account to be found: 88336 > Error!! Account number "88336" not found. > > Choice> f > Enter the number of the account to be found: 64938 > Error!! Account number "64938" not found. > > Choice> f > Enter the number of the account to be found: 20638 > Account Number: 20638 > Account Name: Yorra > Account Balance: 5621 > > > Choice> k > Error!! Invalid Selection. > > Choice> -6 > Error!! Invalid Selection. > > Choice> d > Enter the number of the account to be deleted: 49351 > Error!! Account number "49351" does not exist in database. > > Choice> p > Please choose where the account information should > be printed and hit : > > s) Print to screen > f) Print to file "accounts.out" > r) Return to Main Menu prompt. > > Print Choice> f > > Choice> q > Bye! Thanks for using account. > %cat accounts.out > Account Number: 46783 > Account Name: Pezzoli > Account Balance: 845 > > Account Number: 2984 > Account Name: Rubenstein > Account Balance: 232 > > Account Number: 945 > Account Name: Battle > Account Balance: 67 > > Account Number: 1540 > Account Name: Mary > Account Balance: 398 > > Account Number: 19845 > Account Name: Martin > Account Balance: 0 > > Account Number: 11935 > Account Name: Mutter > Account Balance: 666 > > Account Number: 11972 > Account Name: Cleese > Account Balance: 1962 > > Account Number: 44092 > Account Name: Selman > Account Balance: 98 > > Account Number: 20638 > Account Name: Yorra > Account Balance: 5621 > > Account Number: 50000 > Account Name: Borin > Account Balance: 5746 > > Account Number: 98334 > Account Name: Evans > Account Balance: 2387 > > Account Number: 93221 > Account Name: Cedar > Account Balance: 520 > > Account Number: 73184 > Account Name: Standish > Account Balance: 25 > > %exit > exit > > script done on Wed Apr 14 18:54:55 1999