Question
I need to make an addition to a code that i alreay compiled i need to add file I/O and Fucntions to the code for
I need to make an addition to a code that i alreay compiled i need to add file I/O and Fucntions to the code for iths
Complete phonebook application program by adding saving and loading of the phone book on disk. Also each feature of the application should be in its own function.
the application code is already made, please help me find a way to
Complete phonebook application program by adding saving and loading of the phone book on disk. Also each feature of the application should be in its own function.
Thank You!
-----------------------------------------------
We would like to write a phone book application with the following features.
1- Add a Phone Record: This asks user for the name and the phone number and adds it into the phone book.
2- Search By Name: This asks user to enter a name. Given the name, the program displays the phone number of the record with that name.
3- Search By Phone: This asks user to enter a phone number. Given the phone number, the program displays the name of the record with that phone number.
4- Display All: Reports all the records with their names and phone numbers on screen.
------------------------------------------------------
this was the code
----------------------
# include
int main() {
// int number [10] number can be 10, 200 ... // int number [3] number can be (1,5,3) -- sequnce of values
// int num1; // num1 = 5 --- num1 = int // int num2; [3]; // nu,2 = 1,5,3 ; indeces 0.1.2.3 ... n ---- num2 int,int,int -- 3 int for the intnum2
// int num2; [3]; // num2[0] = 5;
//int num2[3] = 5; //num2[0] = 10; //num2[2] = 15;
//for (int i = 0; i < 3; i++) //{ // cout << num2[i] << endl; //}
// do not want to do any math on these numbers ,, want to keep them just as is -- thats why include as string string name[100]; // name[0], name[1], name[2], name[3], .... name[99], --- last intergere will be number of records - 1 ... so name[99] string number[100]; // name[0], name[1], name[2], name[3], .... name[99], --- last intergere will be number of records - 1 ... so name[99] int count = 0; int choice; for (int i = 0; i < 100; i++) { name[i] = ""; number[i] = ""; } //name[0]<-> number[0] // parallel arrays // run parallel to each other and the values correspond // each item inside name corresponds to each item inisde umber
//We would like to write a phone book application with the following features. //1 - Add a Phone Record : This asks user for the name and the phone number and adds it into the phone book. //2 - Search By Name : This asks user to enter a name.Given the name, the program displays the phone number of the record with that name. //3 - Search By Phone : This asks user to enter a phone number.Given the phone number, the program displays the name of the record with that phone number. //4 - Display All : Reports all the records with their names and phone numbers on screen.
// step 2: Create a program menu // step 3: Enclose menu inside loop to repeat // step 4: Create the if statemetsn inside loop for each feature // step 5: Implement each feature
do {
cout << "***Welcome to Phone Book Application!***" << endl; cout << "1 - Add a Phone Record" << endl; cout << "2 - Search by Name" << endl; cout << "3 - Search by Phone" << endl; cout << "4 - Display All: Report: " << endl; cout << "0 - Exit" << endl; cout << "What do you wan to do?" << endl; cin >> choice;
if (choice == 1) //Feature #1 { string nameToAdd; cout << "What is name? "; cin >> nameToAdd;
string numberToAdd; cout << "What is Phone number? "; cin >> numberToAdd;
// add the name and the number to program data name[count] = nameToAdd; number[count] = numberToAdd;
count++; } else if (choice == 2) // Feature # 2 { cout << "what is name? " << endl; string nameSearch; cin >> nameSearch; bool found = false;
for (int i = 0; i < count; i++) { if (name[i] == nameSearch) { cout << "Number is " << number[i] << endl; found = true; } } if (found == false) { cout << "Name Unidentified! " << endl; } }
else if (choice == 3) // Feature # 3 {
cout << "what is Number? " << endl; string numberSearch; cin >> numberSearch; bool found = false;
for (int i = 0; i < count; i++) { if (number[i] == numberSearch) { cout << "name is " << name[i] << endl; found = true; } }
if (found == false) { cout << "Number Unidentified! " << endl; } }
else if (choice == 4) // Feature # 4 {
for (int i = 0; i < count; i++) { cout << "Name: " << name[i] << endl; cout << "Number: " << number[i] << endl; } }
cout << "" << endl;
} while (choice != 0);
system("pause"); return 0; }
------------------------------------------------------
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started