Advertisement
Dojnaz

Gissa Tal

Sep 25th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp12
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Title = "Gissa Tal";
  14.             Console.WriteLine("Gissa ett tal mellan 1 och 100");
  15.             Random aiRandom = new Random();
  16.             int aiGuess = aiRandom.Next(1, 101);
  17.             while (true)
  18.             {
  19.                 int guess = Convert.ToInt32(Console.ReadLine());
  20.                 if (guess == aiGuess)
  21.                 {
  22.                     Console.WriteLine("Du gissade Rätt!");
  23.                     Console.ReadLine();
  24.                 }
  25.                 if (guess >= aiGuess)
  26.                 {
  27.                     Console.WriteLine("Talet är Mindre");
  28.                 }
  29.                 if (guess <= aiGuess)
  30.                 {
  31.                     Console.WriteLine("Talet är Högre");
  32.                 }
  33.             }
  34.  
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement