Develop a C#.Net windows Application to Calculate the Area and Perimeters of following shapes

  Area and Perimeter Calculation

Design the interface for calculating the area perimeter of the following shapes

  1. Square
  2. Rectangle
  3. Circle
  4. Triangle
  5. Trapezium 
  6. Parallelogram
  7. Kite
  8. Rhombus
 Develop the C#.Net code for calculating the area perimeter of the above-given shapes.

Area and Perimeter Calculation
College of Technology Jaffna, Information and Communication Technology
NVQ Level 5
Nivethiny Mahendran

 


Area and Perimeter Calculation
College of Technology Jaffna, Information and Communication Technology
NVQ Level 5
Sritharan Kokulan

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 Area_and_Perimeter_Calculation
{
   
public partial class Form1 : Form
    {
       
public Form1()
        {
            InitializeComponent();
        }

Square

Square


        private void button1_Click(object sender, EventArgs e)
        {
           
double a = Convert.ToInt32(textBox1.Text);
            textBox2.Text = (a * a).ToString(); //area
            textBox3.Text = (a * 4).ToString(); //perimeter
        }



Circle

Circle

        private void button2_Click(object sender, EventArgs e)
        {
           
double radius = Convert.ToInt32(textBox6.Text);
            textBox5.Text = (2 * 22/7 * radius).ToString(); //area
            textBox4.Text = (22/7 * radius*radius).ToString(); //perimeter
        }

Rectangle


Rectangle


       
private void button3_Click(object sender, EventArgs e)
        {
           
double a = Convert.ToInt32(textBox10.Text);
           
double b = Convert.ToInt32(textBox9.Text);

            textBox8.Text = (a * b).ToString(); //area
            textBox7.Text = ((a + b)*2).ToString(); //perimeter
        }

 Triangle

Triangle

        
private void button4_Click(object sender, EventArgs e)
        {
           
double c = Convert.ToInt32(textBox13.Text);
           
double h = Convert.ToInt32(textBox14.Text);

            textBox12.Text = (0.5 * c * h).ToString(); //area
            textBox11.Text = (a + b + c).ToString(); //perimeter

        }
Trapezium

Trapezium


       
private void button5_Click(object sender, EventArgs e)
        {
           
double a = Convert.ToInt32(textBox18.Text);
           
double b = Convert.ToInt32(textBox17.Text);
           
double c = Convert.ToInt32(textBox19.Text);
           
double d = Convert.ToInt32(textBox20.Text);
           
double h = Convert.ToInt32(textBox21.Text);
            textBox16.Text = (0.5 *(a + d) * h).ToString(); //area
            textBox15.Text = (a + b + c + d).ToString(); //perimeter
        }

Parallelogram

Parallelogram

        private void button6_Click(object sender, EventArgs e)

        {
           
double a = Convert.ToInt32(textBox28.Text);
           
double b = Convert.ToInt32(textBox26.Text);
           
double h = Convert.ToInt32(textBox25.Text);

            textBox23.Text = (a * h).ToString(); //area
            textBox22.Text = (2 * (a + b)).ToString(); //perimeter

}


Kite

Kite

        private void button7_Click(object sender, EventArgs e)
        {
           
double a = Convert.ToInt32(textBox33.Text);
           
double b = Convert.ToInt32(textBox31.Text);
           
double p = Convert.ToInt32(textBox32.Text);
           
double q = Convert.ToInt32(textBox29.Text);

            textBox27.Text = (p * q * 0.5).ToString(); //area
            textBox24.Text = (2 * (a + b)).ToString(); //perimeter
        }


Rhombus

Rhombus

        
private void button8_Click(object sender, EventArgs e)
        {
           
double a = Convert.ToInt32(textBox38.Text);
           
double p = Convert.ToInt32(textBox37.Text);
           
double q = Convert.ToInt32(textBox25.Text);

            textBox34.Text = (p * q * 0.5).ToString(); //area
            textBox30.Text = (4 * a).ToString(); //perimeter
        }
    }
}

Area and Perimeter Calculation
College of Technology Jaffna, Information and Communication Technology
NVQ Level 5
Nithusan S


 

Post a Comment

0 Comments