fork download
  1. //Cecilia Rangel CSC5 Chapter 4, P. 225, #23
  2. //
  3. /**************************************************************
  4.  *
  5.  * Computing magic date
  6.  * ____________________________________________________________
  7.  * This program computes whether or not imputed numbers would
  8.  * would be a magic date
  9.  *
  10.  *This program will utilize the following relational operators:
  11.  * >(greater than), <(less than), and ==(equal to)
  12.  *___________________________________________________________
  13.  * INPUT
  14.  * month : Month of date, in numerical form (1-12)
  15.  * day : Day of date
  16.  * year : Year of date
  17.  *
  18.  * OUTPUT
  19.  * Display : whether or not inputted data is a magic
  20.  * date
  21.  *
  22.  **************************************************************/
  23. #include <iostream>
  24. #include <iomanip>
  25. using namespace std;
  26.  
  27. int main() {
  28. int month;
  29. int day;
  30. int year;
  31.  
  32. cout << "Sometimes, a magical date occurs in which the month ";
  33. cout << "multiplied by the day equals the last two" << endl;
  34. cout << "digits of the year! Enter a date to see if it's a ";
  35. cout << "magical date." << endl;
  36. cout << "Month (1-12): ";
  37. cin >> month;
  38. cout << endl << "Day (1-31) : ";
  39. cin >> day;
  40. cout << endl << "Year (00-99): ";
  41. cin >> year;
  42. cout << endl;
  43. if (month < 1 || month > 12)
  44. cout << "Month must be entered as a number 1-12!";
  45. else if (day < 1 || day > 31)
  46. cout << "Day must be entered as a number 1-31!";
  47. else if (year < 0 || year > 99)
  48. cout << "Year must be entered as two digits!";
  49. else
  50. if (month * day == year)
  51. cout << "This date is brimming with magic! Buy lotto.";
  52. else
  53. cout << "There is nothing magical about this date. Get back to work.";
  54.  
  55. return 0;
  56. }
Success #stdin #stdout 0s 5304KB
stdin
2
7
14
stdout
Sometimes, a magical date occurs in which the month multiplied by the day equals the last two
digits of the year! Enter a date to see if it's a magical date.
Month (1-12): 
Day (1-31)  : 
Year (00-99): 
This date is brimming with magic! Buy lotto.