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 #include string stringToLower(string s) { string result = ""; for (int i = 0; i < s.length(); i++) result += tolower(s[i]);

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

See attached images.

Please help - C++

**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.

```cpp
#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);
}
```

### Explanation:

- **Function `stringToLower`**: 
  - Takes a string `s` as input.
  - Converts each character to lowercase using `tolower()`.
  - Returns the converted lowercase string.

- **Function `isEqual`**: 
  - Takes two strings `s1` and `s2`.
  - Compares them in a case insensitive manner using `stringToLower`.
  - Returns `true` if they are equal, otherwise returns `false`.

- **Function `isGreater`**: 
  - Takes two strings `s1` and `s2`.
  - Converts both strings to lowercase and checks if `s1` is greater than `s2`.
  - Returns `true` if `s1` is lexicographically greater, otherwise returns `false`.
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. ```cpp #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); } ``` ### Explanation: - **Function `stringToLower`**: - Takes a string `s` as input. - Converts each character to lowercase using `tolower()`. - Returns the converted lowercase string. - **Function `isEqual`**: - Takes two strings `s1` and `s2`. - Compares them in a case insensitive manner using `stringToLower`. - Returns `true` if they are equal, otherwise returns `false`. - **Function `isGreater`**: - Takes two strings `s1` and `s2`. - Converts both strings to lowercase and checks if `s1` is greater than `s2`. - Returns `true` if `s1` is lexicographically greater, otherwise returns `false`.
**Educational Webpage Content**

---

### Creating a Contact Information Application

This guide will assist you in building a small application to manage contact information for multiple individuals. The program will maintain the following data for each person in your contact list: name, phone number, and email address. The list can store up to 100 people, utilizing an array of structs to hold these three attributes per contact.

#### Application Main Menu
- **A** - Add Person
- **D** - Delete Person
- **F** - Find and Display Person
- **L** - List All People
- **S** - Save List
- **E** - Exit

**Enter Choice:**

Your application should display this menu continually and execute the selected option until "E" is chosen. There is no need to clear the screen between actions. Users can enter menu choices in upper or lower case.

#### Options Explained:

**Add Person:**
- Prompt the user to enter a name, phone number, and email.
- Ensure the phone number is a string containing only valid characters and verify its validity.
- Validate email format, ensuring it contains "@" followed by a period.

**Delete Person:**
- Reads a name from the user, locates it in the array, and deletes the corresponding data.
- Provide an error message if the person doesn't exist.
- Ensure case-insensitive comparisons.

**Find and Display a Person:**
- Reads a name and displays the corresponding information if found.
- Notify the user if the person is not on the list.
- Utilize case-insensitive searches.

**List All People:**
- Display all contacts sorted by last name.
- Implement case-insensitive bubble sort for sorting.

**Save the List:**
- Save the list to a file named "contacts.txt". Do not allow user modification of this file directly.
- Format each contact’s data as `lastname,firstname,phone,email`.

#### Implementation Considerations:
- Include at least one function for every Main Menu option.
- Duplicate names are not allowed.
- All data modifications occur in-memory and are only written to the file upon saving.
- Use functions for case-insensitive string comparisons.
- Automatically read and populate the array from "contacts.txt" at startup.

**Technical Note:**
- Refer to your textbook (p. 548-549) for using the `isdigit` library function for phone number validation.

This project provides a framework for handling basic contact information through a simple user interface
Transcribed Image Text:**Educational Webpage Content** --- ### Creating a Contact Information Application This guide will assist you in building a small application to manage contact information for multiple individuals. The program will maintain the following data for each person in your contact list: name, phone number, and email address. The list can store up to 100 people, utilizing an array of structs to hold these three attributes per contact. #### Application Main Menu - **A** - Add Person - **D** - Delete Person - **F** - Find and Display Person - **L** - List All People - **S** - Save List - **E** - Exit **Enter Choice:** Your application should display this menu continually and execute the selected option until "E" is chosen. There is no need to clear the screen between actions. Users can enter menu choices in upper or lower case. #### Options Explained: **Add Person:** - Prompt the user to enter a name, phone number, and email. - Ensure the phone number is a string containing only valid characters and verify its validity. - Validate email format, ensuring it contains "@" followed by a period. **Delete Person:** - Reads a name from the user, locates it in the array, and deletes the corresponding data. - Provide an error message if the person doesn't exist. - Ensure case-insensitive comparisons. **Find and Display a Person:** - Reads a name and displays the corresponding information if found. - Notify the user if the person is not on the list. - Utilize case-insensitive searches. **List All People:** - Display all contacts sorted by last name. - Implement case-insensitive bubble sort for sorting. **Save the List:** - Save the list to a file named "contacts.txt". Do not allow user modification of this file directly. - Format each contact’s data as `lastname,firstname,phone,email`. #### Implementation Considerations: - Include at least one function for every Main Menu option. - Duplicate names are not allowed. - All data modifications occur in-memory and are only written to the file upon saving. - Use functions for case-insensitive string comparisons. - Automatically read and populate the array from "contacts.txt" at startup. **Technical Note:** - Refer to your textbook (p. 548-549) for using the `isdigit` library function for phone number validation. This project provides a framework for handling basic contact information through a simple user interface
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY