Advertisement
Guest User

Untitled

a guest
Dec 25th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1.             int num_to_guess;
  2.             int user_guess;
  3.             int score = 0;
  4.             Random rnd = new Random();
  5.             for (int i = 0; i < 10; i++)
  6.             {
  7.                 Console.WriteLine("Round Num {0}", i + 1);
  8.                 int trial_counter = 0;
  9.                 num_to_guess = rnd.Next(1, 100);
  10.                 do
  11.                 {
  12.                     user_guess = int.Parse(Console.ReadLine());
  13.                     trial_counter++;
  14.                     if (user_guess < num_to_guess)
  15.                     {
  16.                         Console.WriteLine("Select bigger num");
  17.                     }
  18.                     else if (user_guess > num_to_guess)
  19.                     {
  20.                         Console.WriteLine("Select smaller num");
  21.                     }
  22.                 }
  23.                 while (user_guess != num_to_guess && trial_counter < 5);
  24.                 if (user_guess == num_to_guess)
  25.                 {
  26.                     Console.WriteLine("hooray, hooray - user guess the correcr number - {0}", num_to_guess);
  27.                     score += 10;
  28.                     Console.WriteLine("SCORE - {0}", score);
  29.                 }
  30.                 else
  31.                 {
  32.                     Console.WriteLine("you failed - the number is {0}", num_to_guess);
  33.                 }
  34.             }
  35.             Console.WriteLine("you SCORE is {0}", score);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement