Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE ANSWER ON TIME AND CORRECT ANSWER, LAST FEW TIMES ANSWER DID NOT WORK. PL

ID: 3571469 • Letter: P

Question

PLEASE ANSWER ON TIME AND CORRECT ANSWER, LAST FEW TIMES ANSWER DID NOT WORK. PLEASE TEST THE .CPP FILE BEFORE SENDDING THE CODE AND PLEASE WRITE ALL #INCLUDE HEADER FUNCTION NAMES.

Write a small application to maintain contact information about people. For each person in your contacts list, you will maintain the following information: name, phone number, and e-mail address. Your list should be able to handle a maximum of 100 people. In this program, you will use an array of structs to store the three attributes of each person in the contact list.

Your application should display the following menu:

     Main Menu

A – Add Person

D – Delete Person

F – Find and Display Person

L - List All People

S - Save List

E – Exit

Enter Choice:

Your program should continue to display the above menu and perform the indicated action until the "E" option is selected. You do not need to clear the screen between each operation; simply allow the display to scroll normally. The user should be able to enter either upper or lower case letters when choosing from the menu.

Each option is described in more detail below.

Add Person:

Prompt for and read a name, phone number, and e-mail address from the user. Use this information to populate the appropriate elements of array. NOTE:

You do not need to validate the phone number, but you should assume that it may contain blanks.

Prompt for the first name separately from the last name. Do not make any assumptions about the content of the name (for example, either the first or last name might be multiple words).

You must validate the email address. For our purposes, a valid email address has no blanks, and it will have the form something@somethingwithatleastonedot

(e.g., bill.bob@oc.eagles.edu, fred@company.com, are all valid addresses). If the email address is invalid, the program should display an error message and allow the user to re-enter.

Delete Person:

Prompt for and read a last name (only). Search the array for the person, and remove their information from the list. For simplicity, you may assume that all last names are unique. Display an appropriate error message if the person is not in the list.

Note: the last name comparison should be case insensitive. Write your own function to perform a case-insensitive comparison.

Find and Display a Person

Prompt for and read a last name (only). Search the array for the person and display all of the information about that person, or an error message if the person is not in the list.

Note: just as with Delete Person, the last name comparison should be case insensitive.

List all People

Display information about every person in the list. This information should be sorted by last name. Use the bubble sort algorithm given in your book (you will need to modify the algorithm to work with this data).

Save the List

Write the contents of the array to a file named "book.txt" in the current directory. You do not need to prompt the user for the name of the file; always use the file book.txt. Existing contents in the file (if any) should be replaced by the new data (this will happen automatically when you open the file for writing (use ofstream). Each person's data should be written on a separate line of the file, in the following format:

            lastname, firstname, phone, e-mail

All values should be comma-separated in the file. The comma is not part of the data in-memory; commas are in the file only to separate the data values. We are not expecting the user to every look at or modify this file directly; all operations on the file are performed by your program.

When your programs starts, it should automatically read and populate the array by reading the book.txt file. If the file is empty or nonexistent, then the program begins its operation with an empty list (this is not considered an error; it just means we have an empty list).

Implementation Issues

•Your solution should contain at least one function per Main-Menu option (i.e., a function to add a person, a function to delete a person, etc.)

•You may assume that there are no duplicate last names in the list.

•All updates (add, deletions) are made in-memory only; do not attempt to update the data directly in the file. At the beginning of the program, you will read the entire file into the array of structs. The user may then add/delete from the list. When the user tells you to save the data, the entire previous contents of the file are replaced with the updated list (using the ofstream will cause this behavior).

Beyond the requirements given above, you must decide what functions you need, the interfaces between the functions, etc. You have some flexibility in how to do this, but part of your grade will be based on how well your program is structured, so put some thought into it. (For example, consider the tasks of finding a person (option F) and deleting a person (option D); there is significant overlap between the logic of these two functions that should be factored out into a third function to avoid duplicating logic).

In addition to normal commenting requirements, every function definition must be preceded by a comment block such as the following:

//======================================================

// displayPeople: display all people, sorted by last name

// parameters:

//    people: the array of structs representing people

//    count: the number of people in the array

// return type: none

//======================================================

void displayPeople(Person people[], int count)
{

….

}

THIS PROJECT IS NOT A GROUP PROJECT. DO NOT LOOK AT ANYONE ELSE'S CODE. NO ONE ELSE SHOULD BE LOOKING AT YOUR CODE TO TELL YOU HOW TO MAKE IT WORK, OR TO FIND OUT HOW TO MAKE THEIR PROGRAM WORK. I WILL FOLLOW THE CHEATING POLICY GIVEN IN THE SYLLABUS.

If there are any known errors in the program when the deadline arrives, you must document the problem in a Word file and attach that file when you submit your assignment. Documented bugs will be penalized less than undocumented bugs!

All variables should be mnemonically-named and commented with a useful comment. All code should be formatted correctly, and commented appropriately.

On the due date, submit the source file to bboard, and hardcopy in class.

Explanation / Answer

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include <fstream.h>
struct contact
{
char name [50];
char phone[10];
char Email[50];
};
void main()
{
contact c[100];
char choice;
while(choice!='E')
{
cout<<"Main Menu ";
cout<<"A-Add Person ";
cout<<"D-Delete Person ";
cout<<"F-Find and Display person ";
cout<<"L-List all People ";
cout<<"S-Save List ";
cout<<"E-Exit ";
cin>>choice;
if(choice=='A')
{// enter info in list
for(int i=0;i<100;i++)
{
cout<<"Enter Name ";
gets(c[i].name);
cout<<"Enter Phone ";
gets(c[i].phone);
cout<<"Enter Email ";
gets(c[i].phone);
}
}
else if(choice=='D')
{
char name1[50];
cout<<"Enter Name ";
gets(name1);
for(int j=0;j<100;j++)
{
   if(strcmp(name1,c[j].name==0)
   { // for searching record in array
   cout<<c[i].name<<" ";
   cout<<c[i].phone<<" ";
   cout<<c[i].email<<" ";
   }
}
}

else if(choice=='F')
{ // code for finding a person and displaying it.

char name2[50];
cout<<"Enter Name ";
gets(name2);
for(int j=0;j<100;j++)
{
   if(strcmp(name1,c[j].name==0)
   {
   }
}
}
else if(choice=='L')
{ // code for listing all persons
for(int j=0;j<100;j++)
{
cout<<c[i].name;
}
}
else if(choice=='S')
{// code for saving data to file
std::fstream fs;
fs.open ("book.txt", std::fstream::in |

std::fstream::out | std::fstream::app);

for(int j=0;j<100;j++)
{
fs<<c[i].name<<" ";
fs<<c[i].phone<<" ";
fs<<c[i].email<<" ";
}

fs.close();

}
else if(choice=='E')
{
// code for exit the program
exit();
}
}
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote