プログラムに少し問題があります。基本的に、窓 (ガラス窓など) の領域を見つけるプログラムを作成する必要があります。数式は、面積 = 高さ * 幅 であり、それが私が入力したものです。ただし、結果は実際には高さ * 幅に答えていません。2 つの数字を同じもの (たとえば、3 * 3) として入力すると、答えは正しい (9) になります。一方、2 つの異なる数値 (たとえば、4 * 5) を入力すると、答えは正しくありません (前の例に対する答えは 25 であると表示されますが、20 のはずです)。なぜこれを行っているのかを理解し、問題を解決するのを手伝ってくれる人はいますか?
PS 学校でのコンピューティングに Microsoft Visual C# 2010 Express を使い始めたばかりです。そのため、かなり単純です。
using System;
namespace FindTheArea
{
class Program
{
static void Main(string[] args)
{
string temporary;
double Height;
double Width;
double Area;
Console.WriteLine("Find The Area");
Console.WriteLine("Please enter the height below");
temporary = Console.ReadLine();
Console.WriteLine("Please enter the Width below");
temporary = Console.ReadLine();
Console.Clear();
Height = double.Parse(temporary);
Width = double.Parse(temporary);
Area = (Height * Width);
Console.WriteLine("The area is...");
Console.WriteLine();
Console.WriteLine(Area+"cm2");
Console.Read();
}
}
}
私は今、どこが間違っていたのかを理解しています。しかし、どうすれば修正できますか?