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

This is the code I have so far: using System; using System.Collections.Generic;

ID: 3605253 • Letter: T

Question

This is the code I have so far:

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;

namespace Lab9_200_Melissa_Thoma
{
public partial class Lab9 : Form
{
public Lab9()
{
InitializeComponent();
}

private void Lab9_Load(object sender, EventArgs e)
{

}

private void btnFormat_Click(object sender, EventArgs e)
{
string city = "";
string state = "";
string zipcode = "";   
city = txtCity.Text;
state = txtState.Text;
zipcode = txtZip.Text;


MessageBox.Show("City, State ,Zip" + city + "," + state + " " + zipcode, "Formatted string");


}

private void btnExit_Click(object sender, EventArgs e)
{
Lab9.ActiveForm.Close();
}
  
  

private void btnParse_Click(object sender, EventArgs e)
{
string emailStr = "";
emailStr = txtEmail.Text;
//check if email is valid
if (!emailStr.Contains("@"))
{
MessageBox.Show("The email address must contain an @ sign.", "Entry Error ");
txtEmail.Focus();
}
else
{

string name = "";
string domain = "";

//index of the @ symbol
int indexPos = emailStr.IndexOf("@");
//get name using substring
name = emailStr.Substring(0, indexPos);
//get domain using substring
domain = emailStr.Substring(indexPos + 1, emailStr.Length - 1 - indexPos);


MessageBox.Show("Name : " + name + " Domain name : " + domain, "Parsed string");

}
}
}

Formatted String City, State, Zip: Edwardsville, IL 62220 0/24/2017 11:56:51 AM OK

Explanation / Answer

namespace Lab9_200_Melissa_Thoma

{

    public partial class Lab9 : Form

    {

        public Lab9()

        {

            InitializeComponent();

        }

        private void Lab9_Load(object sender, EventArgs e)

        {

        }

        private void btnFormat_Click(object sender, EventArgs e)

        {

            string city = "";

            string state = "";

            string zipcode = "";           

            city = txtCity.Text;

            state = txtState.Text;

            zipcode = txtZip.Text;

            MessageBox.Show("City, State ,Zip" + city + "," + state + " " + zipcode, "Formatted string");

        }

        private void btnExit_Click(object sender, EventArgs e)

        {

            Lab9.ActiveForm.Close();

        }

           

       

        private void btnParse_Click(object sender, EventArgs e)

        {

            string emailStr = "";

            emailStr = txtEmail.Text;

            //check if email is valid

            if (!emailStr.Contains("@"))

            {

                MessageBox.Show("The email address must contain an @ sign.", "Entry Error ");

                txtEmail.Focus();

            }

            else

            {

                string name = "";

                string domain = "";

                //index of the @ symbol

                int indexPos = emailStr.IndexOf("@");

                //get name using substring

                name = emailStr.Substring(0, indexPos);

                //get domain using substring

                domain = emailStr.Substring(indexPos + 1, emailStr.Length - 1 - indexPos);

                MessageBox.Show("Name : " + name + " Domain name : " + domain, "Parsed string");

            }

        }

}

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