This program is used to create a phonebook for storing contact information into a text file.
The program begins by asking the user to provide a name for the file that will contain their phone book information. It will then ask the user to provide the names and numbers of their contacts. It should keep asking the user for contact information until they type in Done (case-sensitive).
After the user types Done, store all contact information into the file name they provided at the beginning of the program. If the user does not add any contacts, then the file should be empty.
Please see the sample output below to guide the design of your program.
Sample Output:
Please provide the file name for your phone book: contacts.txt Contact 1: Please provide the name: Elsie Simon Please provide their number: (202)555-0115 Contact 2: Please provide the name: Kaisha Cope Please provide their number: 5455689016 Contact 3: Please provide the name: Sultan Vargas Please provide their number: 371-998-4166 Contact 4: Please provide the name: Done Saving phonebook into contacts.txt Done!
in c++
Q2) This program loads contact information stored in a text file and displays it on the screen.
The program asks the user to provide the filename of a phonebook file. It will then load all of the names and numbers stored in the file and display them on the screen.
We assume that the file is stored using the correct format wherein for each contact, there is always a name followed by their phone number. Below is an example of a possible phonebook file.
Sample phonebook file (phonebook.txt):
Shanay Wickens 7205972770 Harlee Collins 3328206140 Addison Ryan 7917471622
Please see the sample output below assuming it loaded the phonebook file shown above to guide the design of your program. In case there are no contacts, inform the user that there were no contacts stored in the file. If the file does not exist, inform the user that the phonebook file is missing.
Sample Output:
Please provide the file name for your phone book: phonebook.txt Contact 1: Name: Shanay Wickens Number: 7205972770 Contact 2: Name: Harlee Collins Number: 3328206140 Contact 3: Name: Addison Ryan Number: 7917471622
in c++
Hi,Please find the solution and rate the answer. Q2 please post seperately.
#include <iostream>
#include "string"
#include "fstream"
class Contact {
char name[100];
char phone[50];
public:
const char* toString() {
std::string s;
s.append("");
s.append("Name:");
s.append(name);
s.append("Phone");
s.append(phone);
s.append("\n");
return s.c_str();
}
const char *getName() const {
return name;
}
const char *getPhone() const {
return phone;
}
void setName(char *item) {
strcpy(Contact::name, item);
}
void setPhone(char *phone) {
strcpy(Contact::phone, phone);
}
Contact *next;
};
Contact *head;
void add(Contact *newN) {
newN->next = nullptr;
if (head == nullptr) {
head = newN;
return;
}
Contact *temp = head;
while (temp->next != nullptr) {
temp = temp->next;
}
temp->next = newN;
}
char *removeEndNewLine(const char *temp) {
int length = strlen(temp);
char *newCh = new char[length - 1];
strcpy(newCh, temp);
newCh[length - 1] = '\0';
return newCh;
}
int main() {
char data[100];
std::cout << "Please provide the file name for your phone book: ";
fgets(data, 100, stdin);
bool loop = true;
int i = 1;
do {
std::cout << "Contact " << i++;
char name[100], number[20];
std::cout << "Please provide the name:";
fgets(name, 100, stdin);
if (strcmp(removeEndNewLine(name), "Done") == 0) {
break;
}
Contact *temp = new Contact();
temp->setName(removeEndNewLine(name));
std::cout << "Please provide their number:";
fgets(number, 20, stdin);
if(strcmp("\n",number)==0){
fgets(number, 20, stdin);
}
temp->setPhone(removeEndNewLine(number));
add(temp);
} while (loop);
Contact *temp = head;
std::ofstream str;
str.open(removeEndNewLine(data));
while (temp != NULL) {
str << removeEndNewLine(temp->toString());
str<<"\n";
temp = temp->next;
}
str.close();
return 0;
}
Sample out: See the file has stored the output.


This program is used to create a phonebook for storing contact information into a text file....
Phonebook This program is used to create a phonebook for storing contact information into a text file. The program begins by asking the user to provide a name for the file that will contain their phone book information. It will then ask the user to provide the names and numbers of their contacts. It should keep asking the user for contact information until they type in Done (case-sensitive). After the user types Done, store all contact information into the file...
Write a program that will maintain a personal phonebook. The program should be menu driven. Create a new phonebook Print the phonebook Add person to the phonebook Remove a person from the phonebook Sort Modify a person Search for a person by name Save to a data file (Can't be done but leave an error message if the user selects) Retreive phonebook from data file (Can't be done but leave an error message if the user selects) Quit Create a...
Write a contacts database program that presents the user with a menu that allows the user to select between the following options: (In Java) Save a contact. Search for a contact. Print all contacts out to the screen. Quit If the user selects the first option, the user is prompted to enter a person's name and phone number which will get saved at the end of a file named contacts.txt. If the user selects the second option, the program prompts...
In this assignment, you will create an application that holds a list of contact information. You will be able to prompt the user for a new contact, which is added to the list. You can print the contact list at any time. You will also be able to save the contact list. MUST BE IN PYTHON FORMAT Create the folllowing objects: ContactsItem - attributes hold the values for the contact, including FirstName - 20 characters LastName - 20 characters Address...
In this assignment, you will create an application that holds a list of contact information. You will be able to prompt the user for a new contact, which is added to the list. You can print the contact list at any time. You will also be able to save the contact list. Must Be In Python Format Create the following objects: ContactsItem - attributes hold the values for the contact, including FirstName - 20 characters LastName - 20 characters Address...
language:python
VELYIEW Design a program that you can use to keep information on your family or friends. You may view the video demonstration of the program located in this module to see how the program should function. Instructions Your program should have the following classes: Base Class - Contact (First Name, Last Name, and Phone Number) Sub Class - Family (First Name, Last Name, Phone Number, and Relationship le. cousin, uncle, aunt, etc.) Sub Class - Friends (First Name, Last...
Fix the following null pointer error. import java.util.*; import java.io.*; public class PhoneBook { public static void main(String[]args)throws IOException { PhoneBook obj = new PhoneBook(); PhoneContact[]phBook = new PhoneContact[20]; Scanner in = new Scanner(System.in); obj.acceptPhoneContact(phBook,in); PrintWriter pw = new PrintWriter("out.txt"); obj.displayPhoneContacts(phBook,pw); pw.close(); } public void acceptPhoneContact(PhoneContact[]phBook, Scanner k) { //void function that takes in the parameters //phBook array and the scanner so the user can input the information //declaring these variables String fname = ""; String lname = ""; String...
Problem: Contact Information Sometimes we need a program that have all the contact information like name, last name, telephone, direction and something we need to know about that person (notes). Write a program in java language with GUI, classes, arrays, files and inheritance that make this possible. In the first layer, the user should see all the contacts and three buttons (add, delete, edit). *Add button: If the user click the button add, a new layer should appear and should...
In Java.
Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...