Advertisement
Guest User

addMinutesMonths

a guest
May 26th, 2016
508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System;
  2.  
  3. class addMinutesMonths
  4. {
  5. static void Main()
  6. {
  7. // ADD minutes
  8. Console.Write("The time is 10:53");
  9. int hour = 10;
  10. int minutes = 53;
  11.  
  12. Console.WriteLine(". What's the time after 10 minutes?");
  13. int minutesPlusTen = minutes + 10; // 53 + 10 = 63 minutes
  14. hour = hour + (minutesPlusTen / 60); // 10 + (63/60) = 11h
  15. minutes = minutesPlusTen % 60; // 63 % 60 = 3min
  16.  
  17. Console.WriteLine(hour + ":0" + minutes);
  18. Console.WriteLine();
  19.  
  20.  
  21. // ADD months
  22. Console.Write("This is the 10th month. ");
  23. int month = 10;
  24.  
  25. Console.WriteLine("Add 5 months to it.");
  26. int addFive = month + 5; // 10 + 5 = 15
  27.  
  28. Console.WriteLine("Which month do we get? It is the: ");
  29. month = addFive % 12; // 15 % 12 = 3;
  30. Console.WriteLine(month);
  31. Console.WriteLine();
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement