Advertisement
Guest User

HWK advcom 1

a guest
Jan 16th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /*
  2. * Created by SharpDevelop.
  3. * User: cpe
  4. * Date: 1/17/2017
  5. * Time: 9:19 AM
  6. *
  7. * To change this template use Tools | Options | Coding | Edit Standard Headers.
  8. */
  9. using System;
  10.  
  11. namespace sawasdee
  12. {
  13. class Program
  14. {
  15. public static void Main(string[] args)
  16. {
  17. Random r = new Random();
  18. int answer = 1 + (r.Next() % 100);
  19. int g;
  20. int c = 0;
  21.  
  22. do {
  23. c++;
  24. Console.Write("Guess a number: ");
  25. g = int.Parse(Console.ReadLine());
  26. if(g>answer)
  27. Console.WriteLine("Too Large");
  28. else if(g<answer)
  29. Console.WriteLine("Too Small");
  30. } while(g!=answer);
  31.  
  32. Console.WriteLine("That's correct");
  33. Console.WriteLine("Counter: {0}",c);
  34.  
  35. Console.Write("Press any key to continue . . . ");
  36. Console.ReadKey(true);
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement