fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. int month,day,year;
  6. char symbol;
  7.  
  8. do{
  9. cout<<"Enter date: ";
  10.  
  11.  
  12.  
  13. cin>>month>>symbol>>day>>symbol>>year;
  14.  
  15. cin.clear();
  16. cin.ignore(10000,'\n'); // Or better:
  17. // std::numeric_limits<std::streamsize>::max()
  18. // instead of just 10000
  19.  
  20. if(symbol=='/'&&month<=05&&day<=31&&year==2016){
  21. cout<<month<<symbol<<day<<symbol<<year;
  22.  
  23. if(month==01){ // this code is for month of January
  24. if(day==3||day==10||day==17||day==24||day==31){
  25. cout<<" is Sunday.";
  26. }
  27. else if(day==4||day==11||day==18||day==25){
  28. cout<<" is Monday.";
  29. }
  30. else if(day==5||day==12||day==19||day==26){
  31. cout<<" is Tuesday.";
  32. }
  33. else if(day==6||day==13||day==20||day==27){
  34. cout<<" is Wednesday.";
  35. }
  36. else if(day==7||day==14||day==21||day==28){
  37. cout<<" is Thursday.";
  38. }
  39. else if(day==1||day==8||day==15||day==22||day==29){
  40. cout<<" is Friday.";
  41. }
  42. else if(day==2||day==9||day==16||day==23||day==30){
  43. cout<<" is Saturday.";
  44. }
  45.  
  46. }
  47. else if(month==02){ //this code is for month of February
  48. if(day==7||day==14||day==21||day==28){
  49. cout<<" is Sunday.";
  50. }
  51. else if(day==1||day==8||day==15||day==22||day==29){
  52. cout<<" is Monday.";
  53. }
  54. else if(day==2||day==9||day==16||day==23){
  55. cout<<" is Tuesday.";
  56. }
  57. else if(day==3||day==10||day==17||day==24){
  58. cout<<" is Wednesday.";
  59. }
  60. else if(day==4||day==11||day==18||day==25){
  61. cout<<" is Thursday.";
  62. }
  63. else if(day==5||day==12||day==19||day==26){
  64. cout<<" is Friday.";
  65. }
  66. else if(day==6||day==13||day==20||day==27){
  67. cout<<" is Saturday.";
  68. }
  69. }
  70. else if(month==03){ //this code is for month of March
  71.  
  72. if(day==6||day==13||day==20||day==27){
  73. cout<<" is Sunday.";
  74. }
  75. else if(day==7||day==14||day==21||day==28){
  76. cout<<" is Monday.";
  77. }
  78. else if(day==1||day==18||day==15||day==22||day==29){
  79. cout<<" is Tuesday.";
  80. }
  81. else if(day==2||day==9||day==16||day==23||day==30){
  82. cout<<" is Wednesday.";
  83. }
  84. else if(day==3||day==10||day==17||day==24||day==31){
  85. cout<<" is Thursday.";
  86. }
  87. else if(day==4||day==11||day==18||day==25){
  88. cout<<" is Friday.";
  89. }
  90. else if(day==5||day==12||day==19||day==26){
  91. cout<<" is Saturday.";
  92. }
  93. }
  94. else if(month==04){ //this code is for month of April
  95.  
  96. if(day==3||day==10||day==17||day==24){
  97. cout<<" is Sunday.";
  98. }
  99. else if(day==4||day==11||day==18||day==25){
  100. cout<<" is Monday.";
  101. }
  102. else if(day==5||day==12||day==19||day==26){
  103. cout<<" is Tuesday.";
  104. }
  105. else if(day==6||day==13||day==20||day==27){
  106. cout<<" is Wednesday.";
  107. }
  108. else if(day==7||day==14||day==21||day==28){
  109. cout<<" is Thursday.";
  110. }
  111. else if(day==1||day==8||day==15||day==22||day==29){
  112. cout<<" is Friday.";
  113. }
  114. else if(day==2||day==9||day==16||day==23||day==30){
  115. cout<<" is Saturday.";
  116. }
  117. }
  118. else if(month==05){ //this code is for month of May
  119.  
  120. if(day==1||day==8||day==15|day==22||day==29){
  121. cout<<" is Sunday.";
  122. }
  123. else if(day==2||day==9||day==16||day==23||day==30){
  124. cout<<" is Monday.";
  125. }
  126. else if(day==3||day==10||day==17||day==24||day==31){
  127. cout<<" is Tuesday.";
  128. }
  129. else if(day==4||day==11||day==18||day==25){
  130. cout<<" is Wednesday.";
  131. }
  132. else if(day==5||day==12||day==19||day==26){
  133. cout<<" is Thursday.";
  134. }
  135. else if(day==6||day==13||day==20||day==27){
  136. cout<<" is Friday.";
  137. }
  138. else if(day==7||day==14||day==21||day==28){
  139. cout<<" is Saturday.";
  140. }
  141. }
  142. break;
  143. }
  144. else{
  145. cout<<"You have entered an invalid input.\n"<<endl;
  146. }
  147. }while(symbol!='/'||!(month<=05)||!(day<=31)||year!=2016);
  148. return 0;
  149. }
Success #stdin #stdout 0s 3468KB
stdin
dem/dem/dem
1/1/2016
stdout
Enter date: You have entered an invalid input.

Enter date: 1/1/2016 is Friday.