fork download
  1. //Amari Mosley CSC5 Chapter 4, P.220 #3
  2. //
  3. /**************************************************************
  4. *
  5. * Determine Magic Dates
  6. * ____________________________________________________________
  7. * This program will determine whether a date is "magic".
  8. *
  9. *
  10. * Computation is based on the relational operator:
  11. * (month * day == year)
  12. * ____________________________________________________________
  13. * INPUT
  14. * month : Numeric month entered by user
  15. * day : Day entered by user
  16. * year : Two-digit year entered by user
  17. *
  18. * OUTPUT
  19. * Displays whether or not the date is magic
  20. *
  21. **************************************************************/
  22.  
  23. #include <iostream>
  24. #include <iomanip>
  25. using namespace std;
  26.  
  27. // Defining Main Function
  28. int main()
  29. {
  30. // Defining int Variables
  31. int month; // Numeric month entered by user
  32. int day; // Day entered by user
  33. int year; // Two-digit year entered by user
  34.  
  35. // Prompting user to enter month, day, and two-digit year
  36. cout << "Enter a month (in numeric form): ";
  37. cin >> month;
  38. cout << "Enter a day: ";
  39. cin >> day;
  40. cout << "Enter a two-digit year: ";
  41. cin >> year;
  42.  
  43. // Determining if the date is magic and displaying the result
  44. if (month * day == year)
  45. {
  46. cout << "The date is magic." << endl;
  47. }
  48. else
  49. {
  50. cout << "The date is not magic." << endl;
  51. }
  52.  
  53. return 0;
  54. }
Success #stdin #stdout 0.01s 5284KB
stdin
10
31
2007
stdout
Enter a month (in numeric form): Enter a day: Enter a two-digit year: The date is not magic.