Write pseudocode to design a phone contact list program. This is to be in Pseudo
ID: 3720331 • Letter: W
Question
Write pseudocode to design a phone contact list program. This is to be in Pseudocode, specifically not in Java, C++, etc. I am in a class using Tony Gaddis' Starting Out With Programming Logic and Design and this is incredibly basic programming and pseudocode and I am struggling to understand the concept. This question has been asked before but not properly answered. Any help would be greatly appreciated.
Write pseudocode to design a phone contact list program. Your program includes a Graphical User Interface that allows user to add new contacts, update existing contacts, search specific contact from the contact list, sort the contact list in ascending or descending order, delete an old contact. Your program should also provide help screen, an exit button to close the program and displays error messages for any exceptions.
Write a data text file with a list of phone number (10 digits with dashes, 555-555-5555)
Read text file to retrieve contact info (phone number, first name, last name)
Read the file into memory (hint: parallel arrays)
Individual contact info can also be entered from the keypad
Process: (open/read the file, display the menu, close file)
Maintain the phone list by ADD, UPDATE, DELETE, INQUIRE/SEARCH, SORTING
When each item on the menu is done, redisplay the menu
Output: (per each navigation menu item)
Design a GUI screen that include
Keypad with numbers
Navigation menu
Add New Contact ( textbox for first name, last name, textbox for phone number)
Update Contact (search by phone number to display name and phone OR search by name to display name and phone number)
Delete Contact from List (change name to blank)
Inquire: enter phone name or name
List: Sort list either ascending or descending order by first name or last name
Help
Save phone list
Exit
Define a CONTACT class
Fields (phone number, first name, last name)
Set & get method
Constructor
Methods (add, update, delete, save, sort, display the list etc. )
Object: personal contact list Or company phone directory (inheritance)
Public class PersonalContact extends Contact { }
Add:
Enter phone number (phone number: range 1-999)
If not found – display message
If name is blank, enter name (first and last)
If name NOT blank, save contact info, display confirm message
Change:
Enter phone number
If not found – display message
IF found – display name and ask for new name
If name is blank, ask for new name
Delete:
Enter phone number
If not found – display message
If found – display name and confirm delete
If confirm is yes – blank out name
If confirm is no – return to menu
If name is blank, display message
Inquire:
Enter phone number
If found – display name
If not found – display message
If found and name is blank – display message
Sort:
Question: sort ascending, descending or return to menu
If return to menu, then return to menu
If ascending- sort phone number ascending
If descending - sort phone number in descending order
After sort, display phone list
Help:
Display menu option and a one description of the function
Save:
Write phone list back to file
Exit:
If file is open, save phone list, close file
Terminate program
Error:
If a menu selection is made that is not displayed (1-9)
Issue message and display the help screen
This is my project and i need a Pseudocode of this program
Explanation / Answer
source code:-
--------------------
#include<iostream>
#include<iomanip>
#include<string.h>
#include<stdlib.h>
#include<fstream>
using namespace std;
struct PhoneRecord
{
long long phonenumber;
char FirstName[100];
char LastName[100];
char Fulladdress[100];
struct PhoneRecord *next;
};
struct PhoneRecord *first=NULL,*last=NULL,*swapping,*temp=NULL;
class CONTACT {
public:
CONTACT()
{
}
public:
void Add_contact(struct PhoneRecord** head,long phoneno,char firstName[],char LastName[],char Address[])
{
struct PhoneRecord* new_Emp=(struct PhoneRecord*)malloc(sizeof(struct PhoneRecord));
last=*head;
new_Emp->phonenumber=phoneno;
strcpy(new_Emp->FirstName,firstName);
strcpy(new_Emp->LastName,LastName);
strcpy(new_Emp->Fulladdress,Address);
new_Emp->next=NULL;
while (last->next != NULL)
last = last->next;
last->next = new_Emp;
}
public:
void Save_Contacts(ofstream &outfile)
{
struct PhoneRecord *head;
head=temp;
outfile<<"------------------------------------------------------------------------------------"<<endl;
outfile<<" Phone.No"<<setw(15)<<"FirstName"<<setw(15)<<"LastName"<<setw(15)<<"Address"<<setw(15)<<endl;
outfile<<" ---------------------------------------------------------------------------------"<<endl;
while(head!=NULL)
{
outfile<<" "<<head->phonenumber<<setw(15)<<head->FirstName<<setw(15)<<head->LastName<<setw(15)<<head->Fulladdress<<endl;
head=head->next;
}
}
public:
void display_AllContacts()
{
struct PhoneRecord *head;
head=temp;
cout<<"------------------------------------------------------------------------------------"<<endl;
cout<<" Phone.No"<<setw(15)<<"FirstName"<<setw(15)<<"LastName"<<setw(15)<<"Address"<<setw(15)<<endl;
cout<<" ---------------------------------------------------------------------------------"<<endl;
while(head!=NULL)
{
cout<<head->phonenumber<<setw(15)<<head->FirstName<<setw(15)<<head->LastName<<setw(15)<<head->Fulladdress<<endl;
head=head->next;
}
}
public:
int Phone_search(long longkey)
{
int index=0;
struct PhoneRecord* head=temp;
while(head!=NULL)
{
if(key==head->phonenumber)
{
cout<<" The Phone Book Details are:"<<endl;
cout<<head->phonenumber<<setw(15)<<head->FirstName<<setw(15)<<head->LastName<<setw(15)<<head->Fulladdress<<endl;
return index;
}
index++;
head=head->next;
}
return -1;
}
public:
void DeleteContact(struct PhoneRecord **head, int position)
{
if (*head == NULL)
return;
struct PhoneRecord* temp = *head;
if (position == 0)
{
*head = temp->next;
free(temp);
return;
}
for(int i=0; temp!=NULL && i<position-1; i++)
temp = temp->next;
if(temp == NULL || temp->next == NULL)
return;
last = temp->next->next;
free(temp->next);
temp->next = last;
}
public:
static void reverse_emp(struct PhoneRecord** head)
{
struct PhoneRecord* prev = NULL;
struct PhoneRecord* current = *head;
struct PhoneRecord* next = NULL;
while (current != NULL)
{
next = current->next;
current->next = prev;
prev = current;
current = next;
}
*head = prev;
}
public:
void SortContact(struct PhoneRecord **head)
{
int swapped, i;
struct PhoneRecord *start=*head;
struct PhoneRecord *ptr1;
struct PhoneRecord *lptr = NULL;
char temp[100];
if (start == NULL)
return;
do
{
swapped = 0;
ptr1=start;
while (ptr1->next != lptr)
{
if (ptr1->FirstName > ptr1->next->FirstName)
{
swap(ptr1, ptr1->next);
swapped = 1;
}
ptr1 = ptr1->next;
}
lptr = ptr1;
}
while(swapped);
}
void swap(struct PhoneRecord *a, struct PhoneRecord *b)
{
char temp[100];
strcpy(temp, a->FirstName);
strcpy(a->FirstName,b->FirstName);
strcpy(b->FirstName,temp);
}
};
int main()
{
CONTACT obj;
long long phoneno;
char firstname[50];
char lastName[50];
char tempstr[100];
char Address[100];
int option,retval;
ifstream phone_file;
ofstream outfile;
phone_file.open("Phone_contacts.txt");
if(phone_file.is_open())
{
for(int i=0;i<6;i++)
{
temp = (struct PhoneRecord*)malloc(sizeof(struct PhoneRecord));
memset(firstname,0,sizeof(firstname));
memset(lastName,0,sizeof(lastName));
memset(Address,0,sizeof(Address));
phone_file>>phoneno;
phone_file>>firstname;
phone_file>>lastName;
phone_file>>Address;
temp->phonenumber=phoneno;
strcpy(temp->FirstName,firstname);
strcpy(temp->LastName,lastName);
strcpy(temp->Fulladdress,Address);
temp->next=swapping;
swapping=temp;
}
obj.reverse_emp(&temp);
phone_file.close();
cout<<" The Contact Detailsf rom the File is:"<<endl;
obj.display_AllContacts();
}
else
{
cout<<" ! Couldn't Able to Open The File"<<endl;
exit(0);
}
while(true)
{
cout<<" ****** MENU *****"<<endl;
cout<<" 1- Add New Contact"<<endl;
cout<<" 2- Update Contact"<<endl;
cout<<" 3- Delete Contact from List "<<endl;
cout<<" 4- Inquire/Search"<<endl;
cout<<" 5- Sort list"<<endl;
cout<<" 6- Save phone list"<<endl;
cout<<" 7- Help Menu"<<endl;
cout<<" 8.Exit"<<endl;
cout<<" Please Enter Any Option"<<endl;
cin>>option;
switch(option)
{
case 1:
cout<<" Please Enter the Phone Number"<<endl;
cin>>phoneno;
cout<<" Please Enter FirstName"<<endl;
cin>>firstname;
cout<<" Please Enter LastName"<<endl;
cin>>lastName;
cout<<" Please Enter Address"<<endl;
cin>>Address;
obj.Add_contact(&temp,phoneno,firstname,lastName,Address);
cout<<" New Phone Details are Added Successfully"<<endl;
break;
case 2:
cout<<" Please Enter Phone No to update Details "<<endl;
cin>>phoneno;
break;
case 3:
cout<<" Please Enter the Phone Number to delete"<<endl;
cin>>phoneno;
retval=obj.Phone_search(phoneno);
if(retval==-1)
{
cout<<" The Phone Number is Not Exist Please try again"<<endl;
}
else
{
obj.DeleteContact(&temp,retval);
cout<<" The Node is Deleted Successfully"<<endl;
cout<<" The Refresh PhoneBook is:"<<endl;
obj.display_AllContacts();
}
break;
case 4:
cout<<" Please Enter a PhoneNumber: "<<endl;
cin>>phoneno;
retval=obj.Phone_search(phoneno);
if(retval==-1)
cout<<" the Employee Deatails are not Found"<<endl;
break;
case 5:
obj.SortContact(&temp);
break;
case 6:
outfile.open("PhoneFile.txt");
obj.Save_Contacts(outfile);
outfile.close();
break;
case 7:
obj.display_AllContacts();
break;
case 8:
exit(0);
default:
cout<<"Invalid option"<<endl;
}
}
}
Inputtextfile(Phone_contacts.txt):-
-----------------------------------------
9949468557 venkanna koothada Vijaywada
8825712927 Ammulu Koothada Banglore
9505516583 Narayana Chekka Chennai
9514547334 Prudhvi Kumar Vizag
8783438429 Santhan Jujjiv Hyderabad
7018973749 Subhani Khan Tirupathi
Sample Output:-
-------------------------
The Contact Detailsf rom the File is:
------------------------------------------------------------------------------------
Phone.No FirstName LastName Address
---------------------------------------------------------------------------------
9949468557 venkanna koothada Vijaywada
8825712927 Ammulu Koothada Banglore
9505516583 Narayana Chekka Chennai
9514547334 Prudhvi Kumar Vizag
8783438429 Santhan Jujjiv Hyderabad
7018973749 Subhani Khan Tirupathi
****** MENU *****
1- Add New Contact
2- Update Contact
3- Delete Contact from List
4- Inquire/Search
5- Sort list
6- Save phone list
7- Help Menu
8.Exit
Please Enter Any Option
1
Please Enter the Phone Number
9177696576
Please Enter FirstName
manikanta
Please Enter LastName
tati
Please Enter Address
bandar
New Phone Details are Added Successfully
****** MENU *****
1- Add New Contact
2- Update Contact
3- Delete Contact from List
4- Inquire/Search
5- Sort list
6- Save phone list
7- Help Menu
8.Exit
Please Enter Any Option
3
Please Enter the Phone Number to delete
9949468557
The Phone Book Details are:
9949468557 venkanna koothada Vijaywada
The Node is Deleted Successfully
The Refresh PhoneBook is:
------------------------------------------------------------------------------------
Phone.No FirstName LastName Address
---------------------------------------------------------------------------------
8825712927 Ammulu Koothada Banglore
9505516583 Narayana Chekka Chennai
9514547334 Prudhvi Kumar Vizag
8783438429 Santhan Jujjiv Hyderabad
7018973749 Subhani Khan Tirupathi
587761984 manikanta tati bandar
****** MENU *****
1- Add New Contact
2- Update Contact
3- Delete Contact from List
4- Inquire/Search
5- Sort list
6- Save phone list
7- Help Menu
8.Exit
Please Enter Any Option
5
****** MENU *****
1- Add New Contact
2- Update Contact
3- Delete Contact from List
4- Inquire/Search
5- Sort list
6- Save phone list
7- Help Menu
8.Exit
Please Enter Any Option
6
****** MENU *****
1- Add New Contact
2- Update Contact
3- Delete Contact from List
4- Inquire/Search
5- Sort list
6- Save phone list
7- Help Menu
8.Exit
Please Enter Any Option
8
--------------------------------
Process exited after 69.73 seconds with return value 0
Press any key to continue . . .
Outputfile:-
--------------------
------------------------------------------------------------------------------------
Phone.No FirstName LastName Address
---------------------------------------------------------------------------------
8825712927 Ammulu Koothada Banglore
9505516583 Narayana Chekka Chennai
9514547334 Prudhvi Kumar Vizag
8783438429 Santhan Jujjiv Hyderabad
7018973749 manikanta Khan Tirupathi
587761984 Subhani tati bandar
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.