1. Your console application will allow the user to manage contact’s information
ID: 3771482 • Letter: 1
Question
1. Your console application will allow the user to manage contact’s information stored in a disk file (records, in database terminology).
A contact has the following attributes:
• EmpID ;
• First and Last name;
• Phone number;
• Email address.
2. Application will display a 5 option menu with the following choices:
• Input contact;
• Display contact;
• Update contact;
• Save contact to disk;
• Retrieve contact from disk.
Application will allow console user to perform operation corresponding to the chosen menu item.
3. All input data should be validated upon input. For example, negative input values should
result in error messages. A special challenge is to implement the saving of multiple contacts in your file and to enable searching and display of this file.
4. The Display operation will display a contact in a tabular format (see below), including the total value of all the instances of the item in stock:
Name phone email
---- ----- -----
Mario Fernandez (718)100-1234 mario@yahoo.com
John Brown (502)111-2222 jbrown@hotmail.com
5. After our discussion on arrays, extend your application to store your contact list as an array of objects and to maintain a disk file of multiple contacts.
Explanation / Answer
#include <bits/stdc++.h>
using namespace std;
class Employee{
public:
string EmpID;
string name;
string phone_num;
string email_id;
Employee(string m,string p,string e){
EmpID = 1;
name = m;
phone_num = p;
email_id = e;
}
};
int main(){
int n;
while (true){
cout << "1. Input contact " << endl;
cout << "2. Display contact " << endl;
cout << "3. Update contact " << endl;
cout << "4. Save contact to disk " << endl;
cout << "5. Retrieve contact from disk " << endl;
cin >> n;
Employee *emp = NULL;
if (n == 1){
string name;
cout << "Enter Employee name ";
cin >> name;
string phone;
cout << "Enter Phone Number(10 digits without any other characters) ";
cin >> phone;
string email;
cout << "Enter the Email ID ";
cin >> email;
emp = new (name,phone,email);
}
if (n == 2){
cout << "Name phone email" << endl;
cout << "---- ---- ----" << endl;
cout << emp->name << " " << emp->phone_num << " " << emp->email_id << endl;
}
if (n == 3){
cout << "Select what you want to update " << endl;
cout << "1. Name " << endl;
cout << "2. Phone" << endl;
cout << "3. email" << endl;
int m;
cin >> m;
if (m == 1){
cout << "Enter the updated name ";
cin >> emp->name;
}
if (m == 2){
cout << "Enter updated Phone Number(10 digits without any other characters) ";
cin >> emp->phone_num;
}
if (m == 3){
cout << "Enter the updated Email ID ";
cin >> emp->email_id;
}
}
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.