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 trial

C# C# Basics If Statements "if" Statements

Jericoe States
Jericoe States
3,262 Points

I'm stuck, pretty confused now. please help!

I don't understand why this is wrong? why do they want the console to print 55.5 and too fast?

Program.cs
using System;

class Program
{

    static void CheckSpeed(double speed)
    {
        if(speed > 55)
        {
            Console.WriteLine(speed);
        }

        // YOUR CODE HERE
    }

    static void Main(string[] args)
    {
        // This won't print anything.
        CheckSpeed(53);
        // This should print "too fast".
        CheckSpeed(88);
        Console.WriteLine("Too fast");


    }

}

2 Answers

Hi Jericoe,

Inside your if statement, you want to output the message "too fast" as a string, rather than the value contained within speed. So just take out speed and add the required output message.

Also, I don't think you want to alter the Main method at all - I'd leave that alone.

Hope that helps!

Steve.

Mark Wilkowske
PLUS
Mark Wilkowske
Courses Plus Student 18,131 Points

The error is a way of telling you the method has a hole in it. Hint: All the action happens in the method body - evaluate speed and do something else. In Main you have an action that is correct but in the wrong place.