fork download
  1. //Jacob Silvestre CSC5 Chapter 4, P. 220, #3
  2. //
  3. /************************************************************************************
  4. *
  5. * CALCULATE MAGIC BIRTHDATE
  6. *____________________________________________________________________________________
  7. * This program asks the user to enter a month, day, and two-digit year to determine
  8. * calculate whether the date is a magic date. A date is considered magic when the
  9. * month multiplied by the day is equal to the two-digit year.
  10. *
  11. * Magic Date Formula:
  12. * Month x Day = Year
  13. *____________________________________________________________________________________
  14. * INPUT
  15. * month : Month entered as a number
  16. * day : Day entered by user
  17. * year : Two-digit year entered by user
  18. *
  19. * OUTPUT
  20. * Displays whether the date is magic or not
  21. *
  22. **************************************************************************************/
  23.  
  24. #include <iostream>
  25. using namespace std;
  26.  
  27. int main()
  28. {
  29. int month; // INPUT - Month number
  30. int day; // INPUT - Day number
  31. int year; // INPUT - Two-digit year
  32.  
  33. //
  34. // Input Date
  35. //
  36. cout << "Enter the month as a number: ";
  37. cin >> month;
  38.  
  39. cout << "Enter the day: ";
  40. cin >> day;
  41.  
  42. cout << "Enter the two-digit year: ";
  43. cin >> year;
  44.  
  45. //
  46. // Determine if Date is Magic
  47. //
  48. if (month * day == year)
  49. {
  50. cout << "The date is magic!" << endl;
  51. }
  52. else
  53. {
  54. cout << "The date is not magic." << endl;
  55. }
  56.  
  57. return 0;
  58. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Enter the month as a number: Enter the day: Enter the two-digit year: The date is not magic.