Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool is_leap_year(const int year);
  5.  
  6. int main()
  7. {
  8. int year = 0;
  9. int day = 0;
  10. bool day_valid = false;
  11.  
  12. while (!year)
  13. {
  14. cout << "Enter the year: ";
  15. cin >> year;
  16. if (year < 0 || year > 9999)
  17. {
  18. cout << "That's not a valid year!" << endl;
  19. year = 0;
  20. }
  21. }
  22.  
  23. while (!day_valid)
  24. {
  25. cout << "Enter the day of the week of January 1st, using 0 through 6." << endl;
  26. cout << "(0 = Sun, 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 Fri, 6 = Sat)" << endl;
  27. cin >> day;
  28. if (day < 0 || day > 6)
  29. cout << "That's not a valid day! Must be between 0 and 6!" << endl;
  30. else
  31. day_valid = true;
  32. }
  33.  
  34. }
  35.  
  36. bool is_leap_year(const int year)
  37. {
  38. if (year%4==0)
  39. {
  40. if (year % 100 == 0 && year % 400 != 0)
  41. return false;
  42. return true;
  43. }
  44. return false;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement