// Directions: Practice #8-2
// 1) Create a speed string variable.
// 2) Create a speed double variable.
// 2) Write an if-else statment that does a TryParse from the string variable to the double variable.
// 3) Write an if-else statement that displays "Speed is normal" if the value of the the speed variable
// is at least 24 but more than 56.
// 4) If the value is outside the range, dislay "Speed is abnormal".
// 5) Submit your dotnetfiddle link in Blackboard.
using System;
public class Program
{
public static void Main()
//Declare variables
string strSpeed = "45";
double dblSpeed;
//Check if strSpeed's data is valid and convert string to double with Tryparse
if(double.TryParse(strSpeed, out dblSpeed))
//If speed is in between 24 and 56 write "Speed is normal."
if(dblSpeed >= 24 && dblSpeed <= 56)
Console.WriteLine("Speed is normal.");
}
//If speed is not inbetween 24 and 56 write "Speed is abnormal."
else
Console.WriteLine("Speed is abnormal.");
//If data is not valid to convert write error message.
Console.WriteLine("Please enter a valid speed.");