fork download
  1. // Castulo Jason Quintero CSC5 Chapter 4, pg. 220, #3
  2. //
  3. /*******************************************************************************
  4. *
  5. * Determine Whether a Date is a Magic Date
  6. *_______________________________________________________________________________
  7. * This progran collects user input for a month, day, and year in numeric form
  8. * and determines whether the date is magic or not.
  9. * ______________________________________________________________________________
  10. * INPUT
  11. * month : Month of the year
  12. * day : Day of the year
  13. * year : Year using two digits
  14. *
  15. * OUTPUT
  16. * date : Determines whether date is magic or not
  17. *******************************************************************************/
  18. #include <iostream>
  19. using namespace std;
  20.  
  21. int main ()
  22. {
  23.  
  24. int month, //INPUT - month
  25. day, //INPUT - day
  26. year, //INPUT - A Year using two digits
  27. date; //OUTPUT - T/F Determines magic date
  28.  
  29. //Ask the user to enter the month, day, and year
  30. cout << "Enter a Month in numeric form: ";
  31. cin >> month;
  32.  
  33. cout << "\nEnter a Day in numeric form: ";
  34. cin >> day;
  35.  
  36. cout << "\nEnter a Year using only two digits: ";
  37. cin >> year;
  38.  
  39. //Calculate month times day.
  40. date = month * day;
  41.  
  42. //Determine if the date is whether magic or not.
  43. if (date == year)
  44. cout << "\nThe date " << month << "/" << day << "/" << year <<
  45. " is magic!";
  46. else
  47. cout << "\n\nThe date " << month << "/" << day << "/" << year <<
  48. " is not magic!";
  49.  
  50. return 0;
  51. }
Success #stdin #stdout 0.01s 5300KB
stdin
4
07
28

stdout
Enter a Month in numeric form: 
Enter a Day in numeric form: 
Enter a Year using only two digits: 
The date 4/7/28 is magic!