Reputation: 139
using System;
namespace area
{
class Program
{
static void Main(string[] args)
{
double basse;
double height;
Console.WriteLine("Enter your base length: ");
basse = Convert.ToDouble(Console.ReadLine());
Console.WriteLine( "Enter the height: ");
height = Convert.ToDouble(Console.ReadLine());
double area = Program.triangleArea(basse, height);
Console.WriteLine("Your area is {0:f3}", area);
Console.ReadLine();
double pryrmid = Program.pyramidVolume( triangleArea);
Console.WriteLine(" Pyramid Volume is {0:f3}" , pryrmid);
}
public static double triangleArea(double basse, double height)
{
return (0.5 * basse) * height;
}
public static double pyramidVolume (double triangleArea)
{
return (1/3) * triangleArea;
}
}
}
I'm trying the calculate the volume of a pryamid using the methods ive defined.
I keep getting the error
Argument '1': cannot convert from 'method group' to 'double' (CS1503) - \vmware-host\Shared Folders\Documents\SharpDevelop Projects\WS_6_D\WS_6_D\Program.cs:28,57
and
The best overloaded method match for 'area.Program.pyramidVolume(double)' has some invalid arguments (CS1502) - \vmware-host\Shared Folders\Documents\SharpDevelop Projects\WS_6_D\WS_6_D\Program.cs:28,34
I was wondering if someone could help me get on the right track.
Upvotes: 2
Views: 2753
Reputation: 17314
I think you meant to say
double pryrmid = Program.pyramidVolume(area);
instead of
double pryrmid = Program.pyramidVolume( triangleArea);
triangleArea
is your method, you used area
as your result value.
Upvotes: 2
Reputation: 28080
The compiler is expecting something it can evaluate to a double, but you supply the name of a function (triangleArea
).
Instead, you probably want to pass the area
you calculated previously.
Upvotes: 2
Reputation: 47068
The problem is that triangleArea
in
double pryrmid = Program.pyramidVolume( triangleArea);
is not a variable, hence it points to the static method.
Try double pryrmid = Program.pyramidVolume( area);
instead.
Upvotes: 4