fork download
  1. //Andres Guzman CSC5 Chapter 4, P. 220, #3
  2. //
  3. /**************************************************************
  4. *
  5. * DETERMINE IF THE DATE IS MAGIC
  6. * ____________________________________________________________
  7. * This program will compute if the month and day equals the year
  8. *
  9. * Computation is based on the formula:
  10. * magic_date = date * month
  11. * ____________________________________________________________
  12. * INPUT
  13. * day = The inputed day of the month
  14. * month = The inputed month of the year
  15. * year = The inputed year
  16. * OUTPUT
  17. * magic_date = Displays a message if the year can be found with the day and
  18. * month
  19. *
  20. **************************************************************/
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main()
  25. {
  26. int day; //Day of the year
  27. int month; //Month of the year
  28. int year; //The desired year
  29. int magic_date; //The formula needed to display message
  30. //
  31. //
  32. cout << "Day: ";
  33. cin >> day;
  34. cout << "\nMonth: ";
  35. cin >> month;
  36. cout<< "\nYear: ";
  37. cin >> year;
  38. cout << "\n";
  39. //
  40. //
  41. if (day > 31)
  42. cout << "Invalid Day";
  43. if (month > 12)
  44. cout << "\nInvalid Month";
  45. if (year > 99)
  46. cout << "\nInvalid Year\n";
  47. //
  48. //
  49. cout << day << "/" << month << "/" << year << "\n";
  50. //
  51. //
  52. magic_date = day * month;
  53. //
  54. //
  55. if (year == magic_date)
  56. cout << "The date is magic!";
  57. else
  58. cout << "The date is not magic.";
  59. }
Success #stdin #stdout 0.01s 5288KB
stdin
6 10 60
stdout
Day: 
Month: 
Year: 
6/10/60
The date is magic!