Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is in C# format: Download the following file: • GirlNames.txt • BoyNames.tx

ID: 3682832 • Letter: T

Question

This is in C# format:

Download the following file:

• GirlNames.txt
• BoyNames.txt
These files contain a list of the 200 most popular names given boys/girls in the United States
from 2000 through 2009.
Create an application that reads the contents of the two files. The contents of the GirlNames.txt
file should be stored in an array. The contents of the BoyNames.txt file should be stored in a
List.
Sort the girl names array using a Selection sort. Leave the boys List unsorted.
The user should be able to enter a boy’s name, a girl’s name, or both, and the application
should display messages whether the names were among the most popular.
Use a binary search to search the girl names array. Use a sequential search to search the boy
names List.

I think i manage to do the boys part properly, this leaves the girls part. i am really lost in the sort the girl names array using a Selection sort part. I will post the boynames.txt, girlname.txt, gui, and my current code below. I would really appreciate the help i can get here. even if the code below changes a lot, as long as it works it is fine. Thanks.

BoyNames.txt:

Jacob
Michael
Joshua
Matthew
Daniel
Christopher
Andrew
Ethan
Joseph
William
Anthony
David
Alexander
Nicholas
Ryan
Tyler
James

GirlNames.txt:

Lillian
Andrea
Zoe
Faith
Kimberly
Madeline
Alexa
Katelyn
Gabriella
Gabrielle
Trinity
Amanda
Kylie
Mary
Paige
Riley
Jenna
Leah
Sara
Rebecca
Michelle
Sofia
Vanessa
Jordan
Angelina
Caroline
Avery
Audrey
Evelyn
Maya
Claire
Autumn
Jocelyn
Ariana
Nevaeh
Arianna
Jada
Bailey
Brooklyn
Aaliyah
Amber
Isabel
Danielle
Mariah
Melanie
Sierra
Erin
Molly
Amelia
Isabelle

My GUI:

My Current code:

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

namespace NameSearch
{
    public partial class NameSearchForm : Form
    {
        public NameSearchForm()
        {
            InitializeComponent();
        }

        //open boy
        StreamReader inputFile = File.OpenText("BoyNames.txt");
        List<string> nameList = new List<string>();

        //open girl
        StreamReader inputFile2 = File.OpenText("GirlNames.txt");
        List<string> namelist2 = new List<string>();


        private void submitButton_Click(object sender, EventArgs e)
        {
            //Read Boys names
            while (!inputFile.EndOfStream)
            {
                nameList.Add(inputFile.ReadLine());
            }

            //Read girls names
            while (!inputFile2.EndOfStream)
            {
                namelist2.Add(inputFile2.ReadLine());
            }

            List<string> combinedList = new List<string>();
            combinedList.AddRange(nameList);
            combinedList.AddRange(namelist2);

            //Search for name entered by user in both list.
            //Special Note: this is only an experiment on combined list
            //This is for the boys list only, to change it back to search for
            //only boys replace combinedList below with nameList.
            int position = combinedList.IndexOf(textBox1.Text);

            if (position != -1)
            {
                MessageBox.Show("The name you entered is among the most popular names.");
            }

            else
            {
                MessageBox.Show("The name you have entered is not among the most popular names.");
            }

        }
    }
}

Explanation / Answer

Please Go throught the bellow link and download the zip file and run te application plz let me know your comments.

http://we.tl/UqiYNddA4n

//open boy
StreamReader boysInputFile = File.OpenText(@"D:NameSearchNameSearchFilesBoyNames.txt");
List<string> boysNameList = new List<string>();
//open girl
//StreamReader girlsInputFile = File.OpenText(@"D:NameSearchNameSearchFilesGirlNames.txt");
//List<string> girlsNameList = new List<string>();
private void btnSubmit_Click(object sender, EventArgs e)
{
//Read girls names
var girlsNameArry = File.ReadAllLines(@"D:NameSearchNameSearchFilesGirlNames.txt");
//Read Boys names
while (!boysInputFile.EndOfStream)
{
boysNameList.Add(boysInputFile.ReadLine());
}
//Read girls names
//while (!girlsInputFile.EndOfStream)
//{
// girlsNameList.Add(girlsInputFile.ReadLine());
//}
//List<string> combinedList = new List<string>();
//combinedList.AddRange(nameList);
//combinedList.AddRange(namelist2);
//Search for name entered by user in both list.
//Special Note: this is only an experiment on combined list
//This is for the boys list only, to change it back to search for
//only boys replace combinedList below with nameList.
int boysPosition = boysNameList.IndexOf(textInputBoyName.Text);
bool girlsPosition = girlsNameArry.Contains(textInputGirlName.Text);
if (textInputBoyName.Text == "" && textInputGirlName.Text == "")
{
MessageBox.Show("Please enter any one among the most popular Boy's and Girl's name.");
textInputBoyName.Focus();
return;
}
if (textInputBoyName.Text != "" && textInputGirlName.Text == "")
{

if (boysPosition != -1)
{
MessageBox.Show("The name you entered is among the most popular Boy's name.");
}
else
{
MessageBox.Show("The name you have entered is not among the most popular Boy's name.");
}
}
else if (textInputGirlName.Text != "" && textInputBoyName.Text == "")
{

if (girlsPosition == true)
{
MessageBox.Show("The name you entered is among the most popular Girl's names.");
}
else
{
MessageBox.Show("The name you have entered is not among the most popular Girl's name.");
}
}
else
{
if (boysPosition != -1 && girlsPosition == true)
{
MessageBox.Show("The name you entered is among the most popular Boy's and Girl's names.");
}
else if (boysPosition != -1 && girlsPosition == false)
{
MessageBox.Show("The name you entered is among the most popular Boy's name.And not among the most popular Girl's name.");
}
else if (boysPosition == -1 && girlsPosition == true)
{
MessageBox.Show("The name you entered is among the most popular Girl's names.And not among the most popular Boy's name.");
}
else if (boysPosition == -1 && girlsPosition == false)
{
MessageBox.Show("The both names you have entered is not among the most popular Boy's and Girl's name.");
}
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote