Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.Write("Enter your name ");
  13.             String Name;
  14.             Name = Console.ReadLine();
  15.             Console.WriteLine("Guess the secret number," + Name + "");
  16.             Random Rnd = new Random();
  17.  
  18.         ReturnPoint2: // I'll come back to this one later
  19.  
  20.             int secretnum = secretnum = Rnd.Next(1, 100);
  21.             Console.WriteLine("<<psssst...the number is "+secretnum+">>");
  22.         ReturnPoint:
  23.             int guessnum = int.Parse(Console.ReadLine());
  24.  
  25.             if (guessnum > secretnum)
  26.             { Console.Write("Too high."); }
  27.  
  28.             else if (guessnum < secretnum)
  29.             { Console.Write("Too low."); }
  30.  
  31.             else
  32.             { Console.Write("\nCongratulations," + Name + " You guessed correctly!"); }
  33.             while (guessnum != secretnum)
  34.             {
  35.                 Console.WriteLine(" Try again");
  36.                 goto ReturnPoint;
  37.  
  38.             }
  39.  
  40.  
  41.             Console.WriteLine("\n \n \t Try Again? Yes or No \n");
  42.             Console.ReadLine();
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement