Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <iostream>;
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. // Declaring Input Variables
  8. int day; int month; int year;
  9.  
  10. // Asking the user for input
  11. cout << "Please insert date (DD MM YY)\n";
  12. cin >> day >> month >> year;
  13. cout << endl;
  14.  
  15. // Adding day modifier
  16.  
  17. if (day == 01 || day == 21 || day == 31)
  18. {
  19. cout << day << "st ";
  20. }
  21.  
  22.  
  23. else if (day == 02 || day == 22)
  24. {
  25. cout << day << "nd ";
  26. }
  27.  
  28. else if (day == 03 || day == 23)
  29. {
  30. cout << day << "rd ";
  31. }
  32.  
  33. else if (day > 31)
  34. cout << "DAY ERROR ";
  35.  
  36. else
  37. {
  38. cout << day << "th ";
  39. }
  40.  
  41. // Converting the month to text
  42.  
  43. switch (month)
  44. {
  45. case 1: cout << "January "; break;
  46. case 2: cout << "Febuary "; break;
  47. case 3: cout << "March "; break;
  48. case 4: cout << "April "; break;
  49. case 5: cout << "May "; break;
  50. case 6: cout << "June "; break;
  51. case 7: cout << "July "; break;
  52. case 8: cout << "August "; break;
  53. case 9: cout << "September "; break;
  54. case 10: cout << "October "; break;
  55. case 11: cout << "November "; break;
  56. case 12: cout << "December "; break;
  57.  
  58. default: cout << "MONTH ERROR "; break;
  59. }
  60.  
  61. // Print the year at the end
  62.  
  63. cout << year << endl << endl;
  64.  
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement