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

I am working on a program that handels strings so when the user enters their nam

ID: 3889440 • Letter: I

Question

I am working on a program that handels strings so when the user enters their name as a first, middle, and last name the program should parse the given input by the user and display it in a mesage box when the user clicks Parse Name it should display in that message box.

First Name: David

Middle Name: Jones

Last Name: Randel

//////////////////////////////////

Also the phone number:

but the user should not be alowd to enter more then 10 digits. Then when the user clicks edit number buttone displays a message box of the

Number Entered: (333) 333-333

Digits only: 3333333333

Format: 333-333-3333

private void InitializeComponent()

{ // btnEditPhoneNumber

//
this.btnEditPhoneNumber.Location = new System.Drawing.Point(292, 44);
this.btnEditPhoneNumber.Name = "btnEditPhoneNumber";
this.btnEditPhoneNumber.Size = new System.Drawing.Size(154, 19);
this.btnEditPhoneNumber.TabIndex = 10;
this.btnEditPhoneNumber.Text = "Edit Phone Number";
this.btnEditPhoneNumber.Click += new System.EventHandler(this.btnEditPhoneNumber_Click);
//
// btnParseName
//
this.btnParseName.Location = new System.Drawing.Point(292, 9);
this.btnParseName.Name = "btnParseName";
this.btnParseName.Size = new System.Drawing.Size(154, 20);
this.btnParseName.TabIndex = 8;
this.btnParseName.Text = "Parse Name";
this.btnParseName.Click += new System.EventHandler(this.btnParseName_Click);
//
// txtPhoneNumber
//
this.txtPhoneNumber.Location = new System.Drawing.Point(132, 44);
this.txtPhoneNumber.Name = "txtPhoneNumber";
this.txtPhoneNumber.Size = new System.Drawing.Size(87, 20);
this.txtPhoneNumber.TabIndex = 9;
this.txtPhoneNumber.Text = "(609) 221-9801";
//
// txtFullName
//
this.txtFullName.Location = new System.Drawing.Point(132, 9);
this.txtFullName.Name = "txtFullName";
this.txtFullName.Size = new System.Drawing.Size(147, 20);
this.txtFullName.TabIndex = 5;
this.txtFullName.Text = "david jones randel";
//
// lblEnterPhoneNumber
//
this.lblEnterPhoneNumber.Location = new System.Drawing.Point(12, 44);
this.lblEnterPhoneNumber.Name = "lblEnterPhoneNumber";
this.lblEnterPhoneNumber.Size = new System.Drawing.Size(114, 19);
this.lblEnterPhoneNumber.TabIndex = 7;
this.lblEnterPhoneNumber.Text = "Enter phone number:";
this.lblEnterPhoneNumber.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblEnterFullName
//
this.lblEnterFullName.Location = new System.Drawing.Point(12, 9);
this.lblEnterFullName.Name = "lblEnterFullName";
this.lblEnterFullName.Size = new System.Drawing.Size(114, 20);
this.lblEnterFullName.TabIndex = 6;
this.lblEnterFullName.Text = "Enter full name:";
this.lblEnterFullName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;

}

//////////////////////////////////////////This is what i have for the code so far

private void btnParseName_Click(object sender, System.EventArgs e)
{
string fullName = Convert.ToString(txtFullName.Text);
fullName = fullName.Trim();
int firstSpace = fullName.IndexOf(" ");
string firstName = "";
if (firstSpace == -1)
{
firstName = fullName;
}
else
{
firstName = fullName.Substring(0, firstSpace);
MessageBox.Show("First Name: " + firstName);
}
}

private void btnEditPhoneNumber_Click(object sender, System.EventArgs e)
{
string phoneNumber = Convert.ToString(txtPhoneNumber.Text);
phoneNumber = phoneNumber.Insert(3, "-");
phoneNumber = phoneNumber.Insert(7, "-");
MessageBox.Show("Phone Number: " + txtPhoneNumber + " " + "Digits Only:" + phoneNumber +
" " + "Standard Format: " + phoneNumber);
}

Add code to parse the name when the user enters a name and clicks the Parse Name button. This code should work whether the user enters a first, middle, and last name or just a first and last name. It should also convert the parsed name so the first letters are uppercase but the other letters are lowercase. The results should be displayed in a message box like this:

Explanation / Answer

private void InitializeComponent()

{ // btnEditPhoneNumber

//
this.btnEditPhoneNumber.Location = new System.Drawing.Point(292, 44);
this.btnEditPhoneNumber.Name = "btnEditPhoneNumber";
this.btnEditPhoneNumber.Size = new System.Drawing.Size(154, 19);
this.btnEditPhoneNumber.TabIndex = 10;
this.btnEditPhoneNumber.Text = "Edit Phone Number";
this.btnEditPhoneNumber.Click += new System.EventHandler(this.btnEditPhoneNumber_Click);
//
// btnParseName
//
this.btnParseName.Location = new System.Drawing.Point(292, 9);
this.btnParseName.Name = "btnParseName";
this.btnParseName.Size = new System.Drawing.Size(154, 20);
this.btnParseName.TabIndex = 8;
this.btnParseName.Text = "Parse Name";
this.btnParseName.Click += new System.EventHandler(this.btnParseName_Click);
//
// txtPhoneNumber
//
this.txtPhoneNumber.Location = new System.Drawing.Point(132, 44);
this.txtPhoneNumber.Name = "txtPhoneNumber";
this.txtPhoneNumber.Size = new System.Drawing.Size(87, 20);
this.txtPhoneNumber.TabIndex = 9;
this.txtPhoneNumber.Text = "(609) 221-9801";
//
// txtFullName
//
this.txtFullName.Location = new System.Drawing.Point(132, 9);
this.txtFullName.Name = "txtFullName";
this.txtFullName.Size = new System.Drawing.Size(147, 20);
this.txtFullName.TabIndex = 5;
this.txtFullName.Text = "david jones randel";
//
// lblEnterPhoneNumber
//
this.lblEnterPhoneNumber.Location = new System.Drawing.Point(12, 44);
this.lblEnterPhoneNumber.Name = "lblEnterPhoneNumber";
this.lblEnterPhoneNumber.Size = new System.Drawing.Size(114, 19);
this.lblEnterPhoneNumber.TabIndex = 7;
this.lblEnterPhoneNumber.Text = "Enter phone number:";
this.lblEnterPhoneNumber.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblEnterFullName
//
this.lblEnterFullName.Location = new System.Drawing.Point(12, 9);
this.lblEnterFullName.Name = "lblEnterFullName";
this.lblEnterFullName.Size = new System.Drawing.Size(114, 20);
this.lblEnterFullName.TabIndex = 6;
this.lblEnterFullName.Text = "Enter full name:";
this.lblEnterFullName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;

}

//////////////////////////////////////////This is what i have for the code so far

private void btnParseName_Click(object sender, System.EventArgs e)
{
string fullName = Convert.ToString(txtFullName.Text);
fullName = fullName.Trim();
int firstSpace = fullName.IndexOf(" ");
string firstName = "";
if (firstSpace == -1)
{
firstName = fullName;
}
else
{
firstName = fullName.Substring(0, firstSpace);
MessageBox.Show("First Name: " + firstName);
}
}

private void btnEditPhoneNumber_Click(object sender, System.EventArgs e)
{
string phoneNumber = Convert.ToString(txtPhoneNumber.Text);
phoneNumber = phoneNumber.Insert(3, "-");
phoneNumber = phoneNumber.Insert(7, "-");
MessageBox.Show("Phone Number: " + txtPhoneNumber + " " + "Digits Only:" + phoneNumber +
" " + "Standard Format: " + phoneNumber);
}

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