For a school assignment I have to write a program where the program calculates the area of a right triangle. You get the three sides. So I would like to determine with pythagoras what the base is and what the height is. Every time I enter this via assignment I get CS0029 CS0029 cannot implicitly convert type 'double' to 'bool'. Has someone an idea?
class Program
{
static void Main(string[] args)
{
void Opp(double D, double E,out double O)
{
O = (D * E / 2);
}
void Pyth (double F, double G, out double H)
{
H = Math.Sqrt(Math.Pow(F, 2) + Math.Pow(G, 2));
}
Console.WriteLine("Geef de waarde van driehoek 1 in: ");
Console.WriteLine("Zijde a");
double A1 = double.Parse(Console.ReadLine());
Console.WriteLine("Zijde b");
double B1 = double.Parse(Console.ReadLine());
Console.WriteLine("Zijde c");
double C1 = double.Parse(Console.ReadLine());
double DH1;
double PA1 ;
double PB1;
double PC1;
double DH2;
double P2;
Pyth(A1, B1, out PC1);
Pyth(A1, C1, out PB1);
Pyth(C1, B1, out PA1);
if (C1 = PC1)
{
Opp(A1, B1, out DH1);
Console.WriteLine("Oppervlakte driehoek 1 is: " + DH1 + " cm²");
}
else if (B1 = PB1)
{
Opp(A1, C1, out DH1);
Console.WriteLine("Oppervlakte driehoek 1 is: " + DH1 + " cm²");
}
else if (A1 = PA1) {
Opp(C1, B1, out DH1);
Console.WriteLine("Oppervlakte driehoek 1 is: " + DH1 + " cm²");
}
else { Console.WriteLine(" error"); }
Opp(A1,B1,out DH1);
Console.WriteLine("de oppervlakte van driehoek 1 is " + DH1 + "cm²");
double pyth = Math.Sqrt(Math.Pow(A1, 2) + Math.Pow(B1, 2));
Console.WriteLine("controle");
Console.ReadLine();
}
}
}