Answer to Question #325952 in C# for Zarifa

Question #325952

Write a program to print the area and perimeter of a triangle having sides of 3, 4 and 5 units by creating a class named 'Triangle' with the constructor having the three sides as its parameters.( For C sharp with easy code)


1
Expert's answer
2022-04-10T05:24:06-0400
using System;




namespace MathApp


{
    class Program
    {
        public class Triangle
        {
            public int A { get; set; }
            public int B { get; set; }
            public int C { get; set; }
            public Triangle (int a, int b, int c)
            {
                A = a;
                B = b;
                C = c;
            }
            public void Square ()
            {
                double p = (A + B + C) / 2;
                Console.WriteLine($"A = {A}, B = {B}, C = {C}, S = {Math.Sqrt(p*(p-A)*(p-B)*(p-C))}");
            }
        }
        static void Main()
        {
            Triangle FirstTriangle = new (3,4,5);
            FirstTriangle.Square();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS