How would I write a program to build a phone book with name, address I, address
ID: 3652831 • Letter: H
Question
How would I write a program to build a phone book with name, address I, address II, city, state, zip, phone number so that information can be entered, added, sorted, searched and put into alphabetical order?Explanation / Answer
#include #include #include #include #include #include using namespace std; class phonebook { public : phonebook() : MobilNumber(0), lastName(""), firstName(""), pcode(0),Email(""),city(""),Street("") { } void setMobilNumber( int num) { MobilNumber = num; } void setLastName (string lname) { lastName = lname; } void setFirstName(string fname) { firstName = fname; } void setEmail( string mail) { Email = mail; } void setcity (string cty) { city = cty; } void setstreet(string strt) { Street = strt; } void setpcode( int code) { pcode = code; } int getMobilNumber() const { return MobilNumber; } string getLastName() const { return lastName; } string getFirstName() const { return firstName; } int getpcode() const { return pcode; } string getEmail() const { return Email; } string getcity() const { return city; } string getstreet() const { return Street; } private: string firstName; string lastName; int MobilNumber; string Email; string city; string Street; int pcode; }; int enterChoice(); void textFile( fstream& ); void updateRecord( fstream& ); void newRecord( fstream& ); void deleteRecord( fstream& ); void outputLine( ostream&, const phonebook& ); int getmobil( const char * const ); char getname( const char * const ); void searchbyname(fstream&); void searchbyphone(fstream&); enum Choices { TEXTFILE = 1, UPDATE, NEW, DELETE,SEARCH_BY_NAME,SEARCH_BY_PHONE,END}; /*-----------------------------------Main function------------------------------*/ int main() { // note: fstream object, both input and output fstream inOutUser( "credit.dat", ios::in | ios::out ); if ( !inOutUser ) { cerr Email >> city >> Street; person.setLastName( lastName ); person.setFirstName( firstName ); person.setpcode( pcode ); person.setMobilNumber( mobil ); person.setcity( city ); person.setstreet( Street ); person.setEmail( Email); insertInFile.seekp( ( mobil - 1 ) * sizeof( phonebook ) ); insertInFile.write( reinterpret_cast( &person ), sizeof(phonebook ) ); } else cerrRelated 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.