Advertisement
Guest User

Untitled

a guest
Sep 24th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. int yrBorn;
  2.             int year = DateTime.Now.Year;
  3.  
  4.             while (true)
  5.             {
  6.                 Console.WriteLine("How old are you?");
  7.                 int age = int.Parse(Console.ReadLine());
  8.  
  9.                 Console.WriteLine("Did you already have a birthday?");
  10.                 string answer =Console.ReadLine();
  11.  
  12.                 yrBorn = (year - age);
  13.                 if (answer == "Y" || answer == "YES")
  14.                 {  
  15.                     Console.WriteLine("You were born in " + yrBorn);
  16.                 }
  17.                 else
  18.                 {
  19.                     Console.WriteLine("You were born in " + (yrBorn-1));
  20.                 }
  21.  
  22.                 Console.WriteLine("Would you like to try another person?");
  23.                 string answer2 = Console.ReadLine();
  24.  
  25.                 if (answer2 != "Y" && answer2 != "YES")
  26.                 {
  27.                     break;
  28.                 }
  29.             }
  30.  
  31.             Console.ReadKey(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement