fork download
  1. //Zachary Abdollahi CS1A Chapter 4, P. 220, #3
  2. //
  3. /*******************************************************************************
  4.  *
  5.  * DISPLAYING MAGIC DATES
  6.  *
  7.  *______________________________________________________________________________
  8.  * This program asks the user to enter a month, day, and two-digit year, then
  9.  * determines whether the date is "magic" - meaning month times day equals the
  10.  * year.
  11.  *
  12.  * INPUT
  13.  * month : Month entered by the user (numeric form)
  14.  * day : Day entered by user
  15.  * year : Two-digit year entered by the user
  16.  *
  17.  * OUTPUT
  18.  * Message stating whether the date is magic or not
  19.  *
  20.  ******************************************************************************/
  21. #include <iostream>
  22. using namespace std;
  23. int main()
  24. {
  25. int month; //INPUT - Month entered by the user (numeric form)
  26. int day; //INPUT - Day entered by the user
  27. int year; //INPUT - Two-digit year entered by the user
  28.  
  29. // Get input from the user
  30. cout << "Enter a month (numeric form): ";
  31. cin >> month;
  32. cout << "Enter a day: ";
  33. cin >> day;
  34. cout << "Enter a two-digit year: ";
  35. cin >> year;
  36.  
  37. // Determine if the date is magic and display result
  38. if (month * day == year)
  39. {
  40. cout << "That is a magic date!" << endl;
  41. }
  42. else
  43. {
  44. cout << "That is not a magic date." << endl;
  45. }
  46. return 0;
  47. }
Success #stdin #stdout 0s 5320KB
stdin
6
10
61
stdout
Enter a month (numeric form): Enter a day: Enter a two-digit year: That is not a magic date.