using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; /* * Name: Joseph Schuman * Date: 9/22/2015 * Folder: Chap-04-1-AP * Description: Caluclates the length and width to show the area and perimeter of the object. * * */ namespace Chapter4_1AreaAndPerimeter { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnExit_Click(object sender, EventArgs e) { //Close the form. this.Close(); } private void btnCalculate_Click(object sender, EventArgs e) { decimal Length = Convert.ToDecimal(txtLength.Text); decimal Width = Convert.ToDecimal(txtWidth.Text); //Find area of object. var area = Length * Width; //Find perimeter of object. var perimeter = (2 * Length) + (2 * Width); //Display results in Area and Perimeter text boxes. txtArea.Text = area.ToString("f"); txtPerimeter.Text = perimeter.ToString("f"); //Place focus on the Length TextBox txtLength.Focus(); } private void Form1_Load(object sender, EventArgs e) { } } }