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 trialJohn McCafferty
806 PointsNumeric Types
using System;
class Program
{
static double Divide(int numberOne, int numberTwo)
{
double numberOne;
double numberTwo;
numberone / numberTwo;
return;
}
// YOUR CODE HERE: Define a Divide method!
static void Main(string[] args)
{
// This should print "2.5".
Console.WriteLine(Divide(5, 2));
// This should print "3.3333333333..."
// (Or a value close to that, since it can't be
// infinitely precise.)
Console.WriteLine(Divide(10, 3));
}
}
1 Answer
Steven Parker
231,198 PointsYou didn't ask any questions, but here's a few hints about this code:
- you can't define variables with the same name as parameters
- you need to convert the parameters to doubles
- you can use casting for the conversions to avoid creating additional variables
- nothing is being returned by this code, but the method needs to return the result