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 trialjohnchester
6,757 PointsShouldn't this be correct code for the question? C#
Check the code, why does it keep saying its wrong?
using System;
class Program
{
static double Multiply(double first, double second)
{
return first * second;
}
static void Main(string[] args)
{
double total = Multiply(2.5, 2);
Console.WriteLine(total);
double total2 = Multiply(6, 7);
Console.WriteLine(total2);
}
}
2 Answers
Daniel Turato
Java Web Development Techdegree Graduate 30,124 PointsThe challenge requires you not to return the result from multiply but instead output to the console. So you should change the return type on the multiply method from double to void and output the result in that method instead of Main. Otherwise, everything else looks good.
Robert Mukamba
10,774 Pointsusing System;
class Program {
static double Multiply(double first, double second)
{
return first * second;
}
static void Main(string[] args)
{
double total = Multiply(2.5, 2);
double total2 = Multiply(6, 7);
Console.WriteLine(total + (total2));
}
}
Robert Mukamba
10,774 PointsThat is the code that will pass the challenge dear brothers...
johnchester
6,757 Pointsjohnchester
6,757 PointsHow would it go with that method? Im stuck
johnchester
6,757 Pointsjohnchester
6,757 PointsHow would it go with that method? Im stuck
Daniel Turato
Java Web Development Techdegree Graduate 30,124 PointsDaniel Turato
Java Web Development Techdegree Graduate 30,124 PointsSo your code should look like this