lundi 23 décembre 2019

Is there a way of combining the TRY and CATCH method and WHILE loop whilst using the RANDOM function [closed]

Is there a way to combine the try and catch method with the the while function whilst using the RANDOM function.

For Example:

      Console.WriteLine(guess a number);
      int b=Convert.ToInt32( Console.ReadLine());
      Random rnd = new Random();
      rnd.Next(1, 100);
      int a=0;


      while (a<15) 
      {

          try
            {
             Console.WriteLine`("invalid input outside the ranges:");
            }
        catch
            {

                Console.WriteLine("please write only whole numbers");
            }
      a++
    }

Thank you




Aucun commentaire:

Enregistrer un commentaire