Write a small application to maintain contact information about people. For each person in your contacts list, you will maintain the following information: name, phone number, and e-mail address. Your list should be abl to handle a maximum of 100 people. In this program, vou will use an array of structs to store the three ttribute of each person in the contact list. Your application should display the following menu: Main Mon1

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

See attached images!

Please help very confused

structs

no vectors

Write a small application to maintain contact information about people. For each person in your contacts list,
you will maintain the following information: name, phone number, and e-mail address. Your list should be able
to handle a maximum of 100 people. In this program, vou will use an array of structs to store the three atributes
of each person in the contact list.
o See p. 548-549 to see how to use the isdigit library function to make this task easier.
Prompt for the first name separately from the last name. Do not make any assumptions about the
content of the name (for example, either the first or last name might be multiple words).
When the user inputs the email, you should validate it. For our purposes, that means the email
must:
o Contain exactly one @
o Following the @, it must have at least one character, followed by one dot, followed by at
least one character.
Your application should display the following menu:
Main Menu
Delete Person:
A - Add Person
Prompt for and read a last name (only). Search the array for the person, and remove their information
from the list. For simplicity, you may assume that all last names are unique. Display an appropriate error
message if the person is not in the list.
Note: the last name comparison should be case insensitive.
Note: You should not have “blank" entries in your array between names. When you delete an
entry you should “move up" the names after the one you deleted.
D - Delete Person
F - Find and Display Person
L - List All People
S - Save List
E - Exit
Find and Display a Person
Prompt for and read a last name (only). Search the array for the person and display all the information
about that person, or an error message if the person is not in the list.
Note: just as with Delete Person, the last name comparison should be case insensitive.
Enter Choice:
Your program should continue to display the above menu and perform the indicated action until the "E" option
is selected. You do not need to clear the screen between each operation; simply allow the display to scroll
normally. The user should be able to enter either upper or lower case letters when choosing from the menu.
List all People
Display information about every person in the list. This information should be sorted by last name. Use
the bubble sort algorithm given in your book (you will need to modify the algorithm to work with this
data). The comparisons in the sort must be case insensitive.
Each option is described in more detail below.
Save the List
Add Person:
Prompt for and read a name, phone number, and e-mail address from the user. Use this information to
populate the appropriate elements of array. NOTE:
You must validate the phone number. For our purposes, a valid phone number is a string that
contains only digits, dashes, dots, spaces, and parentheses. To keep things simple, you don't
have to verify that the actual content is meaningful, you only have to verify that it doesn’t
contain invalid characters (e.g., we will treat even a phone number like ..-9999) as a valid phone
number).
o Hint: You can access individual characters in a string using standard array notation (eg.,
given that phone is a string variable, you can use phone[i] in a loop to access each
character. Use phone.length() to get the length of the string).
Write the contents of the array to a file named "contacts.txt" in the current directory. Do not prompt the
user for the name of the file; always use the file contacts.txt. Existing contents in the file (if any) should
be replaced by the new data (this will happen automatically when you open the file for writing (use
ofstream to open the file for writing). Each person's data should be written on a separate line of the file,
in the following format:
lastname, firstname,phone,e-mail
All values should be comma-separated in the file (no spaces around commas). The comma is not part of
the data in-memory; commas are in the file only to separate the data values. We are not expecting the
user to ever look at or modify this file directly; all operations on the file are performed by your program.
When your programs starts, it should automatically read and populate the array by reading the contacts.txt file.
If the file is empty or nonexistent, then the program begins its operation with an empty list (this is not
considered an error; it just means we have an empty list).
When the program ends you should ask if the user wants to save their data.
Implementation Issues
Your solution should contain at least one function per Main-Menu option (i.e., a function to add a person, a
function to delete a person, etc.), and you should have additional functions that perform well-defined tasks
(e.g., validate the phone number).
You may assume that there are no duplicate last names in the list.
All updates (add, deletions) are made in-memory only; do not attempt to update the data directly in the file.
At the beginning of the program, you will read the entire file into the array of structs. Your program will
then add/delete from the array in memory. When the user tells you to save the data, the entire previous
contents of the file are replaced with the updated list (using ofstream to write to the file will cause this
behavior).
You can use the functions at the end of this document to do case insensitive string comparisons.
Transcribed Image Text:Write a small application to maintain contact information about people. For each person in your contacts list, you will maintain the following information: name, phone number, and e-mail address. Your list should be able to handle a maximum of 100 people. In this program, vou will use an array of structs to store the three atributes of each person in the contact list. o See p. 548-549 to see how to use the isdigit library function to make this task easier. Prompt for the first name separately from the last name. Do not make any assumptions about the content of the name (for example, either the first or last name might be multiple words). When the user inputs the email, you should validate it. For our purposes, that means the email must: o Contain exactly one @ o Following the @, it must have at least one character, followed by one dot, followed by at least one character. Your application should display the following menu: Main Menu Delete Person: A - Add Person Prompt for and read a last name (only). Search the array for the person, and remove their information from the list. For simplicity, you may assume that all last names are unique. Display an appropriate error message if the person is not in the list. Note: the last name comparison should be case insensitive. Note: You should not have “blank" entries in your array between names. When you delete an entry you should “move up" the names after the one you deleted. D - Delete Person F - Find and Display Person L - List All People S - Save List E - Exit Find and Display a Person Prompt for and read a last name (only). Search the array for the person and display all the information about that person, or an error message if the person is not in the list. Note: just as with Delete Person, the last name comparison should be case insensitive. Enter Choice: Your program should continue to display the above menu and perform the indicated action until the "E" option is selected. You do not need to clear the screen between each operation; simply allow the display to scroll normally. The user should be able to enter either upper or lower case letters when choosing from the menu. List all People Display information about every person in the list. This information should be sorted by last name. Use the bubble sort algorithm given in your book (you will need to modify the algorithm to work with this data). The comparisons in the sort must be case insensitive. Each option is described in more detail below. Save the List Add Person: Prompt for and read a name, phone number, and e-mail address from the user. Use this information to populate the appropriate elements of array. NOTE: You must validate the phone number. For our purposes, a valid phone number is a string that contains only digits, dashes, dots, spaces, and parentheses. To keep things simple, you don't have to verify that the actual content is meaningful, you only have to verify that it doesn’t contain invalid characters (e.g., we will treat even a phone number like ..-9999) as a valid phone number). o Hint: You can access individual characters in a string using standard array notation (eg., given that phone is a string variable, you can use phone[i] in a loop to access each character. Use phone.length() to get the length of the string). Write the contents of the array to a file named "contacts.txt" in the current directory. Do not prompt the user for the name of the file; always use the file contacts.txt. Existing contents in the file (if any) should be replaced by the new data (this will happen automatically when you open the file for writing (use ofstream to open the file for writing). Each person's data should be written on a separate line of the file, in the following format: lastname, firstname,phone,e-mail All values should be comma-separated in the file (no spaces around commas). The comma is not part of the data in-memory; commas are in the file only to separate the data values. We are not expecting the user to ever look at or modify this file directly; all operations on the file are performed by your program. When your programs starts, it should automatically read and populate the array by reading the contacts.txt file. If the file is empty or nonexistent, then the program begins its operation with an empty list (this is not considered an error; it just means we have an empty list). When the program ends you should ask if the user wants to save their data. Implementation Issues Your solution should contain at least one function per Main-Menu option (i.e., a function to add a person, a function to delete a person, etc.), and you should have additional functions that perform well-defined tasks (e.g., validate the phone number). You may assume that there are no duplicate last names in the list. All updates (add, deletions) are made in-memory only; do not attempt to update the data directly in the file. At the beginning of the program, you will read the entire file into the array of structs. Your program will then add/delete from the array in memory. When the user tells you to save the data, the entire previous contents of the file are replaced with the updated list (using ofstream to write to the file will cause this behavior). You can use the functions at the end of this document to do case insensitive string comparisons.
CASE INSENSITIVE STRING COMPARISON
You can use the following functions to do case insensitive string comparison. Place them in your functions file
and include appropriate prototypes in your header file.
#include <string>
#include <cstdlib>
string stringToLower(string s)
{
string result = "";
for (int i = 0; i < s.length(); i++)
result += tolower(s[i]);
return result;
}
bool isEqual(string s1, string s2)
return stringToLower(s1)
stringTolower(s2);
==
}
bool isGreater(string s1, string s2)
{
return stringToLower (s1) > stringToLower(s2); }
Transcribed Image Text:CASE INSENSITIVE STRING COMPARISON You can use the following functions to do case insensitive string comparison. Place them in your functions file and include appropriate prototypes in your header file. #include <string> #include <cstdlib> string stringToLower(string s) { string result = ""; for (int i = 0; i < s.length(); i++) result += tolower(s[i]); return result; } bool isEqual(string s1, string s2) return stringToLower(s1) stringTolower(s2); == } bool isGreater(string s1, string s2) { return stringToLower (s1) > stringToLower(s2); }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Passing Array as Argument
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education