matches.txt file data bellow. ``` Charlie Bradbury F 42 65 N Green 5558675309 Bobby Singer     M 70 69 Y Brown 5558675309 Dean Winchester     M 43 72 N Brown 5558675309 Sam Winchester     M 39 75 N Brown 5558675309 Jody Mills     F 51 65 N Brown 5558675309 Bela Talbot      F 39 69 Y Blue  5558675309 James Novak      M 46 71 Y Blue  5558675309 ``` code.   #include #include #include #include using namespace std; int main() {     char user_gender, user_smoker;     string user_eyecolor;     int user_minAge, user_maxAge, user_minHeight, user_maxHeight;     cout << "What is the gender of your ideal match(M, F, N) ? ";     cin >> user_gender;     cout << "What is the minimum age? ";     cin >> user_minAge;     cout << "What is the maximum age? ";     cin >> user_maxAge;     cout << "What is the minimum height (in inches)? ";     cin >> user_minHeight;     cout << "What is the maximum height (in inches)? ";     cin >> user_maxHeight;     cout << "Smoker (Y/N)? ";     cin >> user_smoker;     cout << "What is the eyecolor (Blue, Green, Grey, Brown)? ";     cin >> user_eyecolor;     cout << endl << endl;     //Variables to check against the conditions     int countGender = 0;     int partialMatch = 0;     int fullMatch = 0;     cout << endl << left << setw(1) << "  Name" << fixed << right << setw(22) << "Age" << fixed << right << setw(12) << "Height" << fixed << right << setw(12) << "Smoker" << fixed << right << setw(15) << "Eye Color" << fixed << right << setw(22) << "Phone" << endl;     cout << "-----------------------------------------------------------------------------------------------------------------" << endl;     //Now read the file data.     ifstream fin("matches.txt");     if (fin.is_open())     {         while (!fin.eof())         {             string firstname, lastname, eyecolor, phoneno;             char gender, smoker;             int age, height;             fin >> firstname >> lastname >> gender >> age >> height >> smoker >> eyecolor >> phoneno;             if (gender == user_gender)             {                 countGender++;                 //Now check to see if the age and height are between the maximum and minum preferences.                  if ((age >= user_minAge && age <= user_maxAge) && (height >= user_minHeight && height <= user_maxHeight))                 {                     //Then check to see if the smoking preference and eye color are also a match.                      if (user_smoker == smoker && user_eyecolor == eyecolor)                     {                         fullMatch++;                         cout << "* " << firstname << "  " << lastname  << setw(25) << age << setw(11) << height << setw(11) << smoker << setw(11) << eyecolor << setw(11) << phoneno << endl;                     }                     else if (eyecolor == user_eyecolor)                     {                         partialMatch++;                         cout << "  " << firstname << "  " << lastname << setw(24) << age << setw(11) << height << setw(11) << smoker << setw(11) << eyecolor<< setw(11) << phoneno << endl;                     }                 }             }         }         cout << "-----------------------------------------------------------------------------" << endl;         cout << "There were " << fullMatch << " matches and " << partialMatch << " partial matches out of " << countGender << " records." << endl;         cout << "-----------------------------------------------------------------------------" << endl;         fin.close();     }     else {         cout << "File did not open";     }     return 0; }

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

matches.txt file data bellow.

```

Charlie Bradbury F 42 65 N Green 5558675309
Bobby Singer     M 70 69 Y Brown 5558675309
Dean Winchester     M 43 72 N Brown 5558675309
Sam Winchester     M 39 75 N Brown 5558675309
Jody Mills     F 51 65 N Brown 5558675309
Bela Talbot      F 39 69 Y Blue  5558675309
James Novak      M 46 71 Y Blue  5558675309

```

code.

 

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;

int main()
{
    char user_gender, user_smoker;
    string user_eyecolor;
    int user_minAge, user_maxAge, user_minHeight, user_maxHeight;

    cout << "What is the gender of your ideal match(M, F, N) ? ";
    cin >> user_gender;

    cout << "What is the minimum age? ";
    cin >> user_minAge;

    cout << "What is the maximum age? ";
    cin >> user_maxAge;

    cout << "What is the minimum height (in inches)? ";
    cin >> user_minHeight;

    cout << "What is the maximum height (in inches)? ";
    cin >> user_maxHeight;

    cout << "Smoker (Y/N)? ";
    cin >> user_smoker;

    cout << "What is the eyecolor (Blue, Green, Grey, Brown)? ";
    cin >> user_eyecolor;

    cout << endl << endl;
    //Variables to check against the conditions
    int countGender = 0;
    int partialMatch = 0;
    int fullMatch = 0;

    cout << endl << left << setw(1) << "  Name" << fixed << right << setw(22) << "Age" << fixed << right << setw(12) << "Height" << fixed << right << setw(12) << "Smoker" << fixed << right << setw(15) << "Eye Color" << fixed << right << setw(22) << "Phone" << endl;
    cout << "-----------------------------------------------------------------------------------------------------------------" << endl;


    //Now read the file data.
    ifstream fin("matches.txt");

    if (fin.is_open())
    {
        while (!fin.eof())
        {
            string firstname, lastname, eyecolor, phoneno;
            char gender, smoker;
            int age, height;
            fin >> firstname >> lastname >> gender >> age >> height >> smoker >> eyecolor >> phoneno;

            if (gender == user_gender)
            {
                countGender++;

                //Now check to see if the age and height are between the maximum and minum preferences. 
                if ((age >= user_minAge && age <= user_maxAge) && (height >= user_minHeight && height <= user_maxHeight))
                {

                    //Then check to see if the smoking preference and eye color are also a match. 
                    if (user_smoker == smoker && user_eyecolor == eyecolor)
                    {
                        fullMatch++;

                        cout << "* " << firstname << "  " << lastname  << setw(25) << age << setw(11) << height << setw(11) << smoker << setw(11) << eyecolor << setw(11) << phoneno << endl;
                    }

                    else if (eyecolor == user_eyecolor)
                    {
                        partialMatch++;

                        cout << "  " << firstname << "  " << lastname << setw(24) << age << setw(11) << height << setw(11) << smoker << setw(11) << eyecolor<< setw(11) << phoneno << endl;
                    }
                }
            }
        }
        cout << "-----------------------------------------------------------------------------" << endl;
        cout << "There were " << fullMatch << " matches and " << partialMatch << " partial matches out of " << countGender << " records." << endl;
        cout << "-----------------------------------------------------------------------------" << endl;

        fin.close();
    }
    else {
        cout << "File did not open";
    }


    return 0;
}

Matching Program
C++.
Create a datafile that contains the first name, last name,
gender, age, height, smoking preference, eye color and
phone number. Add a variety of records to the file. A sample
file looks like:
Charlie Bradbury
Bobby Singer
Dean Winchester
Sam Winchester
Jody Mills
Bela Talbot
James Novak
2 龙 42 38 51 39 45
42
70
43
39
51
96
46
SONSS65
69
72
75
matches.txt
69
71
YNNZ
Green 555-867-5309
Brown 555-867-5309
Brown
Brown
Brown
Blue
Blue
555-867-5309
555-867-5309
555-867-5309
555-867-5309
555-867-5309
Write a program that opens the file and reads the records
one by one. The program will skip any records where the
gender preference is not a match. Of those records that
match the gender preference, check to see if the age and
height are between the maximum and minum preferences.
Then check to see if the smoking preference and eye color
are also a match. If at least 3 of the remaining fields match,
consider the record a partial match, and print it in the
report. If all 4 of the remaining fields match, the record is a
perfect match and print it in the report with an asterisk next
to it. At the end of the program, close the file and report how
many total records there were of the specified gender, how
many were a partial match, and how many were a perfect
match. See the sample output below.
Transcribed Image Text:Matching Program C++. Create a datafile that contains the first name, last name, gender, age, height, smoking preference, eye color and phone number. Add a variety of records to the file. A sample file looks like: Charlie Bradbury Bobby Singer Dean Winchester Sam Winchester Jody Mills Bela Talbot James Novak 2 龙 42 38 51 39 45 42 70 43 39 51 96 46 SONSS65 69 72 75 matches.txt 69 71 YNNZ Green 555-867-5309 Brown 555-867-5309 Brown Brown Brown Blue Blue 555-867-5309 555-867-5309 555-867-5309 555-867-5309 555-867-5309 Write a program that opens the file and reads the records one by one. The program will skip any records where the gender preference is not a match. Of those records that match the gender preference, check to see if the age and height are between the maximum and minum preferences. Then check to see if the smoking preference and eye color are also a match. If at least 3 of the remaining fields match, consider the record a partial match, and print it in the report. If all 4 of the remaining fields match, the record is a perfect match and print it in the report with an asterisk next to it. At the end of the program, close the file and report how many total records there were of the specified gender, how many were a partial match, and how many were a perfect match. See the sample output below.
Smoker (Y/N)? N
What is the eyecolor (Blue, Green, Grey, Brown)? Brown
Name
Bobby Singer
*Dean Winchester
*Sam Winchester
Age
70
43
39
Height Smoker Eye Color
69 72 75
Program ended with exit code:
A run of the program.
What is the gender of your ideal match (M,F,N)? F
What is the minimum age? 20
Y
N
N
Name
*Dean Winchester
Sam Winchester
There were 2 perfect matches and 1 partial matches out of 4 records.
What is the maximum age? 65
What is the
minimum height (in inches)? 60
What is the maximum height (in inches)? 70
Smoker (Y/N)? Y
What is the eyecolor (Blue, Green, Grey, Brown)? Blue
69
Program ended with exit code: 0
Brown
555-867-5309
Brown 555-867-5309
Brown 555-867-5309
Name
Age Height Smoker Eye Color
* Bela Talbot
39
555-867-5309
Blue
There were 1 perfect matches and partial matches out of 3 records.
Phone
Y
Another run of the program.
What is the gender of your ideal match (M,F,N)? M
What is the minimum age? 42
What is the maximum age? 45
What is the minimum height (in inches)? 69
What is the maximum height (in inches)? 90
Smoker (Y/N)? N
What is the eyecolor (Blue, Green, Grey, Brown)? Brown
===
Age Height Smoker Eye Color
43
72
Brown
555-867-5309
555-867-5309
39
75
Brown
There were 1 perfect matches and 1 partial matches out of 4 records.
Phone
Phone
Transcribed Image Text:Smoker (Y/N)? N What is the eyecolor (Blue, Green, Grey, Brown)? Brown Name Bobby Singer *Dean Winchester *Sam Winchester Age 70 43 39 Height Smoker Eye Color 69 72 75 Program ended with exit code: A run of the program. What is the gender of your ideal match (M,F,N)? F What is the minimum age? 20 Y N N Name *Dean Winchester Sam Winchester There were 2 perfect matches and 1 partial matches out of 4 records. What is the maximum age? 65 What is the minimum height (in inches)? 60 What is the maximum height (in inches)? 70 Smoker (Y/N)? Y What is the eyecolor (Blue, Green, Grey, Brown)? Blue 69 Program ended with exit code: 0 Brown 555-867-5309 Brown 555-867-5309 Brown 555-867-5309 Name Age Height Smoker Eye Color * Bela Talbot 39 555-867-5309 Blue There were 1 perfect matches and partial matches out of 3 records. Phone Y Another run of the program. What is the gender of your ideal match (M,F,N)? M What is the minimum age? 42 What is the maximum age? 45 What is the minimum height (in inches)? 69 What is the maximum height (in inches)? 90 Smoker (Y/N)? N What is the eyecolor (Blue, Green, Grey, Brown)? Brown === Age Height Smoker Eye Color 43 72 Brown 555-867-5309 555-867-5309 39 75 Brown There were 1 perfect matches and 1 partial matches out of 4 records. Phone Phone
Expert Solution
Step 1

The given C++ program is as follows:

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;

int main()
{
    char user_gender, user_smoker;
    string user_eyecolor;
    int user_minAge, user_maxAge, user_minHeight, user_maxHeight;

    cout << "What is the gender of your ideal match(M, F, N) ? ";
    cin >> user_gender;

    cout << "What is the minimum age? ";
    cin >> user_minAge;

    cout << "What is the maximum age? ";
    cin >> user_maxAge;

    cout << "What is the minimum height (in inches)? ";
    cin >> user_minHeight;

    cout << "What is the maximum height (in inches)? ";
    cin >> user_maxHeight;

    cout << "Smoker (Y/N)? ";
    cin >> user_smoker;

    cout << "What is the eyecolor (Blue, Green, Grey, Brown)? ";
    cin >> user_eyecolor;

    cout << endl << endl;
    //Variables to check against the conditions
    int countGender = 0;
    int partialMatch = 0;
    int fullMatch = 0;

    cout << endl << left << setw(1) << "  Name" << fixed << right << setw(22) << "Age" << fixed << right << setw(12) << "Height" << fixed << right << setw(12) << "Smoker" << fixed << right << setw(15) << "Eye Color" << fixed << right << setw(22) << "Phone" << endl;
    cout << "-----------------------------------------------------------------------------------------------------------------" << endl;


    //Now read the file data.
    ifstream fin("matches.txt");

    if (fin.is_open())
    {
        while (!fin.eof())
        {
            string firstname, lastname, eyecolor, phoneno;
            char gender, smoker;
            int age, height;
            fin >> firstname >> lastname >> gender >> age >> height >> smoker >> eyecolor >> phoneno;

            if (gender == user_gender)
            {
                countGender++;

                //Now check to see if the age and height are between the maximum and minum preferences. 
                if ((age >= user_minAge && age <= user_maxAge) && (height >= user_minHeight && height <= user_maxHeight))
                {

                    //Then check to see if the smoking preference and eye color are also a match. 
                    if (user_smoker == smoker && user_eyecolor == eyecolor)
                    {
                        fullMatch++;

                        cout << "* " << firstname << "  " << lastname  << setw(25) << age << setw(11) << height << setw(11) << smoker << setw(11) << eyecolor << setw(11) << phoneno << endl;
                    }

                    else if (eyecolor == user_eyecolor)
                    {
                        partialMatch++;

                        cout << "  " << firstname << "  " << lastname << setw(24) << age << setw(11) << height << setw(11) << smoker << setw(11) << eyecolor<< setw(11) << phoneno << endl;
                    }
                }
            }
        }
        cout << "-----------------------------------------------------------------------------" << endl;
        cout << "There were " << fullMatch << " matches and " << partialMatch << " partial matches out of " << countGender << " records." << endl;
        cout << "-----------------------------------------------------------------------------" << endl;

        fin.close();
    }
    else {
        cout << "File did not open";
    }


    return 0;
}

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Still not working for other user inputs as shown in the sreenshot.

Kindly, would you please check for all the three sample output as well? Thank you.

C: Microsoft Visual Studio Debug Console
What is the minimum age? 0
What is the maximum age? 100
What is the minimum height (in inches)? 45
What is the maximum height (in inches)? 90
Smoker (Y/N)? N
What is the eyecolor (Blue, Green, Grey, Brown)? Blue
Name
Dean Winchester
Sam Winchester
James Novak
■
46
DELL
Age
43
N
39
Height
71
72
O
75
●
Smoker
Y
There were 0 matches and 3 partial matches out of 4 records.
C:\_
N
N
Eye Color
Brown
Brown
C:\Users\demusu\Documents\aims\fall_2022\Computer_science (c++)\assignments\Matching.2\x64\Debug\Matching.2.exe (process
30156) exited with code 0.
Press any key to close this window
Blue
Phone
5558675309
5558675309
5558675309
40°F Sunny
(8)
›)
9:16 AM
10/17/2022
Transcribed Image Text:C: Microsoft Visual Studio Debug Console What is the minimum age? 0 What is the maximum age? 100 What is the minimum height (in inches)? 45 What is the maximum height (in inches)? 90 Smoker (Y/N)? N What is the eyecolor (Blue, Green, Grey, Brown)? Blue Name Dean Winchester Sam Winchester James Novak ■ 46 DELL Age 43 N 39 Height 71 72 O 75 ● Smoker Y There were 0 matches and 3 partial matches out of 4 records. C:\_ N N Eye Color Brown Brown C:\Users\demusu\Documents\aims\fall_2022\Computer_science (c++)\assignments\Matching.2\x64\Debug\Matching.2.exe (process 30156) exited with code 0. Press any key to close this window Blue Phone 5558675309 5558675309 5558675309 40°F Sunny (8) ›) 9:16 AM 10/17/2022
Solution
Bartleby Expert
SEE SOLUTION
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