The problem stands at line 23 and 25.
double r.length = Convert.ToDouble(Console.ReadLine());
double r.width = Convert.ToDouble(Console.ReadLine());
I don't know how to make the conversion from string to double so that the program would take double numbers from the user.
My programming teacher once made it but I forgot to note it.
class Rectangle
{
double length;
double width;
public double GetArea()
{
return length * width;
}
public void Display()
{
Console.WriteLine("Length: "+length);
Console.WriteLine("Width: "+ width);
Console.WriteLine("Area: "+ GetArea());
}
}
class ExecuteRectangle
{
static void Main(string[] args)
{
Rectangle r = new Rectangle();
Console.WriteLine("Length= ");
double r.length = Convert.ToDouble(Console.ReadLine()); // <===
Console.WriteLine("Width= ");
double r.width = Convert.ToDouble(Console.ReadLine())); // <===
Console.Writeline("Area= ");
r.Display();
Console.ReadLine();
}
}