【发布时间】:2017-11-13 00:18:13
【问题描述】:
老实说,我真的很困惑,甚至不知道从哪里开始。我尝试了几种不同的编码方式,但它返回了很多错误,我不确定我是否开始做对了。
问题如下
编写一个从用户那里读取三角形边长的应用程序。使用 Heron 公式(如下)计算面积,其中 s 代表三角形周长的一半,a、b、&c 代表三个边的长度。将区域打印到小数点后三位。
// Compute semi-perimeter and then area
s = (a + b + c) / 2.0d;
area = Math.Sqrt(s*(s-a) * (s - b) * (s - c));
这是给我的可视化 C# 类的
任何形式的帮助将不胜感激!
更新 到目前为止,我不确定其中是否正确
我目前收到的唯一错误是 CS5001(程序不包含适合入口点的静态“main”方法
感谢任何帮助,即使它说所有这些都是错误的
namespace Heron {
class HeronsFormula {
public static void main(String[] args) {
Console.WriteLine("type tbh to find the area of triangle through heron's formula");
string typedvalue = Console.ReadLine();
if (typedvalue == "tbh") {
Console.WriteLine("Type the value of first side");
string side1 = Console.ReadLine();
Console.WriteLine("Type the value of second side");
string side2 = Console.ReadLine();
Console.WriteLine("type the value of third side");
string side3 = Console.ReadLine();
double fside = double.Parse(side1);
double sside = double.Parse(side2);
double thside = double.Parse(side3);
double s = (fside + sside + thside) / 2.0;
double har = Math.Sqrt(s * (s - fside) * (s - sside) * (s - thside));
Console.ReadLine();
}
}
}
}
更新 2
【问题讨论】:
-
链接到我原来的帖子,上面有最后作业格式的例子。 social.msdn.microsoft.com/Forums/vstudio/en-US/…
-
这里有什么问题?
-
欢迎来到 Stack Overflow。这不是家庭作业完成服务;你需要做你自己的工作。你的老师给你它是为了评估你对课程材料的理解,如果我们做这个评估就不会发生。如果您无法开始,请向您的讲师寻求帮助 - 他们正在获得报酬来教您。祝你好运。
-
我已经尝试过编码,我的编码尝试在链接中(在评论中发布时遇到了问题)
-
仍然不清楚您面临什么问题。您应该在问题中在此处发布代码。
标签: c# math triangular