C# C# Basics If Statements "if" Statements

Chukwunonso Emmanuel
PRO
Chukwunonso Emmanuel
Pro Student 3,046 Points

if the speed is over 55

Program.cs
using System;

class Program
{

    static void CheckSpeed(double speed)
    {
        // YOUR CODE HERE
    }

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

}

1 Answer

Martin Murphy
Martin Murphy
19,318 Points

A simple if statement in CheckSpeed should do this:

using System;

class Program
{

    static void CheckSpeed(double speed)
    {
        // YOUR CODE HERE
        if (speed > 55)
        {
            Console.WriteLine("too fast");
        }
    }

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