Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add code to format the city, state, and zip code when the user clicks the Format button. Also include the current date and time. -Create

Add code to format the city, state, and zip code when the user clicks the Format button. Also include the current date and time. -Create string variables that contains the city, state, and zip code and assign them to each textbox. Use the Trim method on city state and zip and the ToUpper method on the state. ( string city, state zip) - Create a DateTime variable and assign it to the current date and time using the Now function. - Create an integer variable to hold the length of the city. (int cityLength = city.Length) -Create a string variable to hold the city state and zip concatenated together. String cityStateZip = city + state + zip - A comma after the city length needs to be inserted and then a space between the state and the zip code which is the 4 position after the city length. (cityStateZip = cityStateZip.Insert(cityLength, ", ")) and (cityStateZip = cityStateZip.Insert(cityLength + 4, " ") - You can assume that the user enters appropriate data in each text box. Display the results in a message box like the second one shown below. Put the date and time on a separate line. image text in transcribed

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago

Question

Explain the functions of financial management.

Answered: 1 week ago

Question

HOW MANY TOTAL WORLD WAR?

Answered: 1 week ago