harp Chapter 7 P: 6 Boys and Girls Name search  Name Search for boys name from a text file called Boys names. Need to display if it is a popular name, and what postion it is in. I have only written code for a boy search and have not coded the postion text box let.  I can't get anything to display in the NameSearchText box ??   using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Search_Names_B_and_G {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         private void searchNameButton_Click(object sender, EventArgs e)         {

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

C Sharp Chapter 7 P: 6 Boys and Girls Name search 

Name Search for boys name from a text file called Boys names. Need to display if it is a popular name, and what postion it is in. I have only written code for a boy search and have not coded the postion text box let.  I can't get anything to display in the NameSearchText box ??

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Search_Names_B_and_G
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void searchNameButton_Click(object sender, EventArgs e)
        {
        }// declare varaibles 
        string[] boysNames;

        private void Form1_Load(object sender, EventArgs e)
        {// Call the 
            SearchBoys_Click(sender, e);
        }

        private void SearchBoys_Click(object sender, EventArgs e)
        {// use a try block 
            try
            {
                // Declare a StreamReader variable.
                StreamReader inputFile;

                // Open the file and get a StreamReader object.
                inputFile = File.OpenText("C:\\Users\\shari\\OneDrive\\BoysNames.txt");//able to open txt in Visual 

                int namesList = 0; // varaible for the amount of names = 200 

                //loop executes till the end of the file 
                while (!inputFile.EndOfStream)
                {
                    //Read the input from the file 
                    inputFile.ReadLine();
                    //move to the next name by increment by +1 
                    namesList++;
                }
                //create an array varaible for the Name List 
                boysNames = new string[namesList];
                // Open  the boys file 
                inputFile = File.OpenText("BoysNames.txt");

                int index = 0;

                //Loop executes until the end of file / Use (!) operator for bool T or F 
                while (index < boysNames.Length && !inputFile.EndOfStream)
                {//insert buys names into the array 
                    boysNames[index] = inputFile.ReadLine();
                }
                //increment the index 
                index++;
                // Close the file
                inputFile.Close();

            }

            catch (Exception ex)
            {
                //Display a message error 
                MessageBox.Show(ex.Message);
            }


            // Set search label to empty 
            NameSearchTextBox.Text = "";
            // (!=) Not equal  an empty string 
            if (NameSearchTextBox.Text!= "")
            {// check if popular name 
                Boolean popularBoysName = false;

                for (int i = 0; i < boysNames.Length; i++)
                {
                    if (boysNames[i] == NameSearchTextBox.Text)
                    {
                        popularBoysName = true;
                        break;
                    }
                }

                //Display the name in label 
                if (popularBoysName == true)
                {
                    popularTextBox.Text += NameSearchTextBox.Text + " is a popular boys name/n";
                }
                else
                {
                    popularTextBox.Text += NameSearchTextBox.Text + " is not a populor buys name./n";
                }
            }
        }
    }
}
        
    Name list , i was not able to upload the txt file 

Jacob
Michael
Joshua
Matthew
Daniel
Christopher
Andrew
Ethan
Joseph
William
Anthony
David
Alexander
Nicholas
Ryan
Tyler
James
John
Jonathan
Noah
Brandon
Christian
Dylan
Samuel
Benjamin
Zachary
Nathan
Logan
Justin
Gabriel
Jose
Austin
Kevin
Elijah
Caleb
Robert
Thomas
Jordan
Cameron
Jack
Hunter
Jackson
Angel
Isaiah
Evan
Isaac
Mason
Luke
Jason
Gavin
Jayden
Aaron
Connor
Aiden
Aidan
Kyle
Juan
Charles
Luis
Adam
Lucas
Brian
Eric
Adrian
Nathaniel
Sean
Alex
Carlos
Bryan
Ian
Owen
Jesus
Landon
Julian
Chase
Cole
Diego
Jeremiah
Steven
Sebastian
Xavier
Timothy
Carter
Wyatt
Brayden
Blake
Hayden
Devin
Cody
Richard
Seth
Dominic
Jaden
Antonio
Miguel
Liam
Patrick
Carson
Jesse
Tristan
Alejandro
Henry
Victor
Trevor
Bryce
Jake
Riley
Colin
Jared
Jeremy
Mark
Caden
Garrett
Parker
Marcus
Vincent
Kaleb
Kaden
Brady
Colton
Kenneth
Joel
Oscar
Josiah
Jorge
Cooper
Ashton
Tanner
Eduardo
Paul
Edward
Ivan
Preston
Maxwell
Alan
Levi
Stephen
Grant
Nicolas
Omar
Dakota
Alexis
George
Collin
Eli
Spencer
Gage
Max
Cristian
Ricardo
Derek
Micah
Brody
Francisco
Nolan
Ayden
Dalton
Shane
Peter
Damian
Jeffrey
Brendan
Travis
Fernando
Peyton
Conner
Andres
Javier
Giovanni
Shawn
Braden
Jonah
Cesar
Bradley
Emmanuel
Manuel
Edgar
Erik
Mario
Edwin
Johnathan
Devon
Erick
Wesley
Oliver
Trenton
Hector
Malachi
Jalen
Raymond
Gregory
Abraham
Elias
Leonardo
Sergio
Donovan
Colby
Marco
Bryson
Martin

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
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