Garciano, Kissy Cyrine A. February 21, 2022 Windows Forms App No.1 Program code: usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing;...


Garciano, Kissy Cyrine A. February 21, 2022



Windows Forms App



No.1 Program code:



usingSystem;


usingSystem.Collections.Generic;


usingSystem.ComponentModel;


usingSystem.Data;


usingSystem.Drawing;


usingSystem.Linq;


usingSystem.Text;


usingSystem.Threading.Tasks;


usingSystem.Windows.Forms;



namespacerectangle


{


publicpartialclassForm1: Form


{


publicForm1()


{


InitializeComponent();


}



privatevoidbutton1_Click(objectsender, EventArgs e)


{


doublelength = 0, width = 0, perimeter = 0, area = 0;


length = Convert.ToDouble(textBox1.Text);


width = Convert.ToDouble(textBox2.Text);


perimeter = 2 *(length + width);


area = length * width;



textBox3.Text = Convert.ToString(perimeter);


textBox4.Text = Convert.ToString(area);




}


}


}



Output




My explanation



When making a Windows Forms app, Go to Visual Studio and click "Create New Project." After that, type Windows Form Appin the search bar of your visual studio. When you search for it, click and choose the Windows forms app that has.Net.Put your own name in the files. For example, "area." Then go to "next" and start your Windows Forms App. After that, click "view" where you can find the toolbox, and then click the toolbox where you can find the label, button, and textbox. Double click the button to add more codes to your windows form and then run the code to find the length and width of the rectangle and calculate the perimeter and area to know how the codes work and understand the formula for the rectangle. Do not forget to click the perimeter textbox, right click, and click properties. In the properties section, choose enabled and then click false, and in the area textbox, click false also, so that when asking for each dimension, you will get the result.



No.2


Program code:



usingSystem;


usingSystem.Collections.Generic;


usingSystem.ComponentModel;


usingSystem.Data;


usingSystem.Drawing;


usingSystem.Linq;


usingSystem.Text;


usingSystem.Threading.Tasks;


usingSystem.Windows.Forms;



namespacearea


{


publicpartialclassForm1: Form


{


publicForm1()


{


InitializeComponent();


}



privatevoidlabel1_Click(objectsender, EventArgs e)


{



}



privatevoidbutton1_Click(objectsender, EventArgs e)


{


doubleradius = 0, perimeter = 0, area = 0;


radius = Convert.ToDouble(textBox1.Text);


perimeter = 2 * Math.PI * radius;


area = Math.PI * radius * radius;


textBox2.Text = Convert.ToString(perimeter);


textBox3.Text = Convert.ToString(area);


}


}


}



Output:













My explanation:





To run the code, find the formula for the circle and use it in your code. Once you know the formula, it is easy for you to calculate the radius of the circle. The next step is, when done labelling and putting text into the textbox, double click "calculate" so that you will see the code and start coding. Do not forget to right click the textbox and click
"properties",then click "enabled" to
"false", same as the area textbox, click "false" because that is an output, not an input.

Jun 01, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here