This is all new to me and I could really use the help. Not exactly what to do so
ID: 441677 • Letter: T
Question
This is all new to me and I could really use the help. Not exactly what to do so please make proper adjustments. I am using C to program. Please show finished product. Thank you Information to go by: Write a program to maintain a phone book. The phone book must be maintained as a linked list. Your program must have the following menu: 1. Add entry The user will be prompted to enter a name and a phone number, and the entry will be inserted into the list. 2. Lookup number The user will be prompted to enter the name they are looking for, if the name exists, it will print the entire entry. If not, print "not found". You can assume for this assignment there will not be multiple entries with the same name. Hint: consider using strcmp to compare the name entered with the name in each phonebook entry. 3. Delete entry The user will be prompted to enter the last name of the user to be deleted. The matching entry will be displayed with a message to confirm the deletion (y/n). Upon confirmation, the entry will be deleted. If the deletion is not confirmed, they will be returned to the main menu. 4. Print the entire address book. 5. Quit Make sure you make proper use of functions and proper code formatting #include#include#include#include#include#include using namespace std; void menu(); void addPatient(); void viewRecords(); void viewAllRecords(); void viewOneRecord(); void display(); void deleteMechanism(); void editRecord(); void menuDisplay(); void viewOneMechanism(); void deleteRecord(); void question(); struct studinfo { int idno; char name[25]; char address[25]; }; FILE *Patfile; FILE *tempPatfile; int id; bool found; main() { int a; printf(" "); for(a=1; a<=49; a++){ printf("*"); } printf(" WELCOME "); for(a=1; a<=49; a++){ printf("*"); } getch(); system("cls"); menu(); } void menu() { int choice=0; while(choice!='E') { system("cls"); menuDisplay(); printf(" Type the letter of your choice: "); scanf("%c", &choice); choice = toupper(choice); switch(choice) { case 'A':{addPatient();break;} case 'B':{viewRecords();break;} case 'C':{deleteRecord();break;} case 'D':{editRecord();break;} } } } void menuDisplay() { printf(" P O E B E and J A I' S"); printf(" Phonebook"); printf(" ************************************"); printf("********************************************"); printf(" C H O I C E S"); printf(" - - - - - - - - - - - - - - -"); printf(" [A] ADD Contact"); printf(" [B] VIEW Contacts"); printf(" [C] DELETE ONE Contact"); printf(" [D] EDIT Contacts "); printf(" [E] EXIT"); printf(" - - - - - - - - - - - - - - -"); } void addPatient() { int cntct,num; found=false; char name[25],address[25]; studinfo students; printf(" Contact number:"); scanf("%d", &num); Patfile=fopen("Profile.txt","a+"); rewind(Patfile); while(!feof(Patfile)&& found==false) { fscanf(Patfile,"%d%s%s",&cntct,&name,&address); if(cntct==num) { printf("Number is Existing!.."); found=true; } } if(found==false) { printf(" Name:"); scanf("%*c%s", &name); printf(" Address:"); scanf("%s", &address); fprintf (Patfile, " %-5d %-20s %-20s",num,name,address); printf(" The new record was successfully saved!"); } getch(); fclose(Patfile); } void viewRecords() { system("cls"); char c; printf(" View One Contacts or View All Contacts?"); printf(" [Press [A] to view One Record]"); printf(" [Press [B] to view All Records]"); printf(" Enter Choice: "); scanf("%c", &c); c=toupper(c); switch(c) { case 'A': viewOneRecord(); break; case 'B': viewAllRecords(); break; default: system("cls"); return viewRecords(); break; } question(); } void question() { char e; printf(" Do you want another Transaction?[Y/N]:"); scanf("%*c%c", &e); e=toupper(e); switch(e) { case 'Y': system("cls"); return viewRecords(); break; case 'N': system("cls"); return menu(); break; default: system("cls"); return question(); break; } } void viewAllRecords() { int idno; char name[25],address[25]; Patfile=fopen("Profile.txt","r"); rewind(Patfile); if(!feof(Patfile)) { system("cls"); cout<<" LIST OF CONTACTS"; display(); while(!feof(Patfile)) { if(fscanf(Patfile,"%d%s%s",&idno,&name,&address)>0) cout<<setw(15)<<idno<<setw(25)<<name<<setw(25)<<address<<" "; } } else{ printf("No record found in the file!");} fclose(Patfile); getch(); } void viewOneRecord() { viewOneMechanism(); getch(); } void deleteRecord() { char cont; viewOneMechanism(); if (found==true) { cout<<"Are you sure you want to delete this record(y/n)?:"; cin>>cont; if(cont=='y'||cont=='Y') { deleteMechanism(); cout<<" The record was successfully deleted!"; } else { cout<<" The record was not deleted!"; } getch(); } } void editRecord() { char cont; char name[25],address[25]; viewOneMechanism(); if(found==true) { printf(" Are you sure you want to update this record(y/n)?:"); scanf("%c", &cont); cont=toupper(cont); if(cont=='Y') { deleteMechanism(); Patfile=fopen("Profile.txt","a+"); cout<<" Type Name:"; cin>>name; cout<<" Type Address:"; cin>>address; fprintf (Patfile, " %-5d %-20s %-20s",id,name,address); fclose(Patfile); cout<<" The record was successfully updated!"; } else { cout<<" The record was not updated!"; } getch(); } } void display() { cout<<" "<<setw(15)<<left<<"Contact no." <<setw(25)<<left<<"Name" <<setw(25)<<left<<"Address"<<" "; } void deleteMechanism() { int idno; char name[25],address[25]; Patfile=fopen("Profile.txt","r"); tempPatfile=fopen("tempProfile.txt","w+"); rewind(Patfile); while(!feof(Patfile)) { if(fscanf(Patfile,"%d%s%s",&idno,&name,&address)>0) { if(idno!=id) { fprintf (tempPatfile, " %-5d %-20s %-20s",idno,name,address); } } } fclose(Patfile); fclose(tempPatfile); Patfile=fopen("Profile.txt","w+"); tempPatfile=fopen("tempProfile.txt","r"); rewind(tempPatfile); while(!feof(tempPatfile)) { if(fscanf(tempPatfile,"%d%s%s",&idno,&name,&address)>0) { if(idno!=id) { fprintf (Patfile, " %-5d %-20s %-20s",idno,name,address); } } } fclose(Patfile); fclose(tempPatfile); } void viewOneMechanism() { int idno; char name[25],address[25]; found=false; printf(" Enter CONTACT to be viewed:"); cin>>id; Patfile=fopen("Profile.txt","r"); rewind(Patfile); while(!feof(Patfile)&&found==false) { if(fscanf(Patfile,"%d%s%s",&idno,&name,&address)>0) { if(idno==id) { display(); cout<<setw(15)<<idno<<setw(25)<<name<<setw(25)<<address<<" "; found=true; } } } if(found==false) { printf(" Record is not existing!"); } fclose(Patfile); }Explanation / Answer
Im sry ur question is totally messed up.. !
all things are mixed
so before posting question
"click on advance editor just below where u write question
then paste whole program "
then click post question / ask question thanx
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.