fork download
  1. //Saliha Babar CS1A Chapter 4, Page 220, #3
  2. //
  3. /************************************************************************
  4.  *
  5.  * DETERMINATION OF MAGIC DATE
  6.  * ______________________________________________________________________
  7.  * This program determine if the date is magic based on day, month
  8.  * and year entered.
  9.  *
  10.  * Determination of magic date:
  11.  * year == days * months
  12.  *________________________________________________________________________
  13.  * INPUT
  14.  *
  15.  * month : numerical month entered by user
  16.  * day : numerical day entered by user
  17.  * year : numerical year entered by user
  18.  *
  19.  * OUTPUT
  20.  * validation of magic date
  21.  * *********************************************************************/
  22. #include <iostream>
  23. using namespace std;
  24.  
  25. int main() {
  26. int year; // INPUT - numerical year entered by user
  27. int month; // INPUT - numerical month entered by user
  28. int day; // INPUT - numerical day entered by user
  29.  
  30. // Get user input
  31. cout << "Enter a year, in two digits\n";
  32. cin >> year;
  33.  
  34. cout << "Enter any month in numerical form\n";
  35. cin >> month;
  36.  
  37. cout << "Enter any day of that month in numerical form\n";
  38. cin >> day;
  39.  
  40.  
  41. // Determination of magic date
  42. if (year == month * day )
  43. {
  44. cout << "Wow! That is a magic date.\n";
  45. }
  46. else
  47. {
  48. cout << "Sorry, that is not a magic date :(\n";
  49. }
  50.  
  51. return 0;
  52. }
Success #stdin #stdout 0s 5284KB
stdin
30
06
05
stdout
Enter a year, in two digits
Enter any month in numerical form
Enter any day of that month in numerical form
Wow! That is a magic date.