Another problem with methods
Create a console-based application named Area. Include
three overloaded methods that compute the area of a
rectangle when two dimensions are passed to it. One
method takes two integers as parameters, one takes two
doubles, and the third takes an integer and a double.
Write a Main() method that demonstrates each method
works correctly.
I have done this
Console.WriteLine("Enter the hight of the rectangle:");
double stNumber = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter the hight of the rectangle:");
double ndNumber = Convert.ToDouble(Console.ReadLine());
AreaOfRectangle(ref stNumber, ref ndNumber);
}
static void AreaOfRectangle(ref int length,ref int width)
{
int area;
area = length * width;
Console.WriteLine("The area of rectangle is {0}", area);
}
static void AreaOfRectangle(ref double length,ref double width)
{
double area;
area = length * width;
Console.WriteLine("The area of rectangle is {0}", area);
}
static void AreaOfRectangle(ref int length,ref double width)
{
double area;
area = length * width;
Console.WriteLine("The area of rectangle is {0}", area);
}
You think there's better way to do it?