我想知道如何编写一个控制台应用程序,该应用程序获取等边三角形的高度和边长并显示其周长和面积
//Triangle Area = 1/2(base x height)
Console.Writeline("Please write the b value of the triangle:")`enter code here`
double bSide = double.Parse(Console.ReadLine());
Console.write("Please write the h value of your triangle:")
double hSide = double.Parse(Console.ReadLine());
double area = (bSide * hSide) / 2;
Console.Writeline("The area of your triangle is:", area);
答案 0 :(得分:0)
键入C#语法时,必须注意字符大小写,也要注意缺少分号。 IDE和弯曲的红色线条会警告您这些错误...
//Triangle Area = 1/2(base x height)
Console.WriteLine("Please write the b value of the triangle:");
double bSide = double.Parse(Console.ReadLine());
Console.Write("Please write the h value of your triangle:");
double hSide = double.Parse(Console.ReadLine());
double area = (bSide * hSide) / 2;
Console.WriteLine("The area of your triangle is:" + Convert.ToString(area));
Console.ReadLine();
答案 1 :(得分:0)
//Triangle Area = 1/2(base x height)
Console.Writeline("Please write the b value of the triangle:")`enter code here`
double bSide = double.Parse(Console.ReadLine());
Console.write("Please write the h value of your triangle:")
double hSide = double.Parse(Console.ReadLine());
double area = (bSide * hSide) / 2;
Console.Writeline("The area of your triangle is:{0}", area.ToString());
Console.ReadLine();