daily pastebin goal
58%
SHARE
TWEET

asdas

a guest Feb 14th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             // Pg 185 Ex 37 Seif A
  2.  
  3.             Random rnd = new Random();
  4.             int count = 1, computer_guess, your_guess;
  5.             computer_guess = rnd.Next(1, 101);
  6.             Console.WriteLine("Enter your guess: ");
  7.             your_guess = int.Parse(Console.ReadLine());
  8.             while ((count <= 10) && (your_guess != computer_guess))
  9.             {
  10.                 if (your_guess > computer_guess)
  11.                     Console.WriteLine("Your guess is too high");
  12.                 else
  13.                     Console.WriteLine("Your guess is too low");
  14.                 count++;
  15.                 Console.WriteLine("Enter your guess");
  16.                 your_guess = int.Parse(Console.ReadLine());
  17.             }
  18.             if (your_guess == computer_guess)
  19.                 Console.WriteLine("very good ,you have got the number correct in " + count + " trails");
  20.             else
  21.                 Console.WriteLine("Too many guesses");
  22.  
  23.             // Pg 185 Ex 37 Seif B
  24.  
  25.             Random rnd = new Random();
  26.             int count = 1, maxRange, minRange, computer_guess, your_guess;
  27.             Console.WriteLine("Enter the maximum range: ");
  28.             maxRange = int.Parse(Console.ReadLine());
  29.             Console.WriteLine("Enter the minimum range: ");
  30.             minRange = int.Parse(Console.ReadLine());
  31.             computer_guess = rnd.Next(minRange, maxRange + 1);
  32.             Console.WriteLine("Enter your guess: ");
  33.             your_guess = int.Parse(Console.ReadLine());
  34.             while ((count <= 10) && (your_guess != computer_guess))
  35.             {
  36.                 if (your_guess > computer_guess)
  37.                     Console.WriteLine("Your guess is too high");
  38.                 else
  39.                     Console.WriteLine("Your guess is too low");
  40.                 count++;
  41.                 Console.WriteLine("Enter your guess");
  42.                 your_guess = int.Parse(Console.ReadLine());
  43.             }
  44.             if (your_guess == computer_guess)
  45.                 Console.WriteLine("very good ,you have got the number correct in " + count + " trails");
  46.             else
  47.                 Console.WriteLine("Too many guesses");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top