Answer to Question #333575 in C# for Brody

Question #333575

How do you display an error message written like this: (“101 is not a valid mark, enter a number between 0 and 100”) in this code?


1
Expert's answer
2022-04-25T16:59:17-0400


using System;


class Program {
  public static bool isVaild(int num)
  {
    if(num>=0&&num<100)
    {
      return true;
    }
    return false;
  }
  public static void Main (string[] args) {
        int num=Convert.ToInt32(Console.ReadLine());
        while(!isVaild(num))
        {
          Console.WriteLine($"{num} is not a valid mark, enter a number between 0 and 100");
          num=Convert.ToInt32(Console.ReadLine());
        }
        Console.ReadKey();
    }
  }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS