I've been trying to solve this problem about my program about printing the final result of Area of Triangle using Heron's Formula with user input
static void Main(string[] args)
{
//variable/s declaration
double a, b, c, Area;
//Ask for the values of the three sides of the triangle.
Console.Write("Enter first side: ");
a = double.Parse(Console.ReadLine());
Console.Write("Enter second side: ");
b = double.Parse(Console.ReadLine());
Console.Write("Enter third side: ");
c = double.Parse(Console.ReadLine());
//instantiate a triangle
Triangle KD = new Triangle();
Area =KD.FindingA();
//display the values of the three sides and the area of the triangle
Console.WriteLine("First Side = {0:R}", a);
Console.WriteLine("Second Side = {0:R}", b);
Console.WriteLine("Third Side = {0:R}", c);
Console.WriteLine("Area of triangle = {0:R}", Area);
}
public class Triangle
{
//fields
private double A, B, C, s, Area;
public double a, b, c;
//constructors
public double GetASide()
{ return this.a; }
public void SetASide(double value)
{ this.a = value; }
public double GetBSide()
{ return this.b; }
public void SetBSide(double value)
{ this.b = value; }
public double GetCSide()
{ return this.c; }
public void SetCSide(double value)
{ this.c = value; }
//create a method that will compute the area of the triangle
public double FindingA()
{
s = (a + b + c)/2;
Area = Math.Sqrt(s * (s - a) * (s - b) * (s - c));
return Area;
}
where for the output should be
First Side = 5.1
Second Side = 5.1
Third Side = 3.2
Area of triangle = 7.7480
But when I input it, it shows
First Side = 5.1
Second Side = 5.1
Third Side = 3.2
Area of triangle = 0
Please help me with this problem guys, I can't think any solution of the problem