Click here to Skip to main content
16,005,491 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, i'm working in visual studio and i'm getting this error.
CS7036 C# There is no argument given that corresponds to the required formal parameter of 'side1' of 'Triangle.CalculateArea(int, int, int)'

I'm also getting the same area with side2, and side3.

this is the code
public void SidesMethod()
   {
       int side1;
       int side2;
       int side3;


       Console.Write("Enter the length of the first side");
       side1 = int.Parse(Console.ReadLine());

       Console.Write("Enter the length of the third side");
       side2 = int.Parse(Console.ReadLine());

       Console.Write("Enter the length of the third side");
       side3 = int.Parse(Console.ReadLine());

       CalculateArea(side1);
       CalculateArea(side2);
       CalculateArea(side3);
   }

   public double CalculateArea(int side1, int side2, int side3)
   {


   }


I'm still pretty new to this and I know I have a lot to learn but i've tried researching this myself and I just can't see to find a way to fix it. If anymore of the code is needed just let me know.

What I have tried:

Looking into the quick actions suggested by visual studio as well as some things related to similar questions to this that i've found on this website as well as others.
Posted
Updated 22-Feb-20 9:54am

1 solution

Your CalculateArea method has 3 parameters; you have to provide them all when you call it, and store the result in a variable:
C#
double result = CalculateArea(side1, side2, side3);
You should also validate user inputs and account for cases where input string is not a valid integer:
C#
Console.Write("Enter the length of the first side");
while (!int.TryParse(Console.ReadLine(), out side1)) { }

Console.Write("Enter the length of the second side");
while (!int.TryParse(Console.ReadLine(), out side2)) { }

Console.Write("Enter the length of the third side");
while (!int.TryParse(Console.ReadLine(), out side3)) { }
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900