Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 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 ConsoleApplication10
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. DateTime localDate = DateTime.Now;
  14.  
  15. Console.WriteLine("Mamy rok:" + localDate.Year);
  16.  
  17. List<int> graduationYears = new List<int>();
  18. List<int> evenGraduationYears = new List<int>();
  19. int endYear;
  20. do
  21. {
  22. Console.WriteLine("Wprowadź za ile lat zakończysz studia");
  23. String yearLeft = Console.ReadLine();
  24. int numberLeft = Int32.Parse(yearLeft);
  25. endYear = localDate.Year + numberLeft;
  26. Console.WriteLine("Studia skończymy w:" + endYear);
  27. graduationYears.Add(endYear);
  28. graduationYears.ForEach(listElement => Console.Write("{0}\n", listElement));
  29. } while (endYear < 2030);
  30.  
  31. graduationYears.ForEach(listElement =>
  32. {
  33. if ((listElement % 2) == 0)
  34. {
  35. evenGraduationYears.Add(listElement);
  36. };
  37. });
  38. Console.WriteLine("Parzyste lata, które wpisano:");
  39. evenGraduationYears.ForEach(listElement => Console.Write("{0},", listElement));
  40. Console.WriteLine("\n");
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement