Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDaniel Burczyk
3,331 PointsNeed Help! Define a Multiply Function
Need help finding out why this isn't going through. It says it isn't passing but has correct output to console.
using System;
class Program
{
static double Multiply(double firstParameter, double secondParameter)
{
return firstParameter * secondParameter;
}
// YOUR CODE HERE: Define a method named Multiply. Remember
// to use the "static" and "void" keywords: "static void
// Multiply" (without quotes). Multiply should take two
// "double" values as parameters.
static void Main(string[] args)
{
double firstParameter = Multiply(2.5, 2);
Console.WriteLine(firstParameter);
double secondParameter = Multiply(6, 7);
Console.WriteLine(secondParameter);
}
}
1 Answer
Steven Parker
231,248 PointsThe instructions say the Multiply method "accepts two parameters, multiplies them together, and passes the result to Console.WriteLine." They also say "Use the static
and void
keywords in the method definition.", but the code here is returning double instead of void.
So the output should be done inside the Multiply method, and the Main method should only do two calls.