fork download
  1. //Jeremy Huang CS1A Chapter 4, P. 220, #3
  2. //
  3. /**************************************************************
  4.  *
  5.  * CALCULATE INTEREST EARNED
  6.  * ____________________________________________________________
  7.  * This program calculates the total amount of savings and
  8.  * interest earned after one year based on a given principal,
  9.  * interest rate, and the number of times the interest is
  10.  * compounded annually.
  11.  * ____________________________________________________________
  12.  * INPUT
  13.  * month : the month
  14.  * day : the day
  15.  * year : the year
  16.  *
  17.  * OUTPUT
  18.  * N/A :cout shows whether it is magic or not
  19.  *
  20.  **************************************************************/
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main() {
  25. int month; //INPUT - the month
  26. int day; //INPUT - the day
  27. int year; //INPUT - the year
  28.  
  29. //User Input
  30. cout<<"Please enter a month in numeric form,"
  31. <<" no zeros if it is a single digit: "<<endl;
  32. cin>>month;
  33. cout<<"Please enter a day in numeric form,"
  34. <<" no zeros if it is a single digit: "<<endl;
  35. cin>>day;
  36. cout<<"Please enter the last 2 digits of a year: "<<endl;
  37. cin>>year;
  38.  
  39. //Output Result
  40. if ((month*day)==year)
  41. cout<<"The date "<<month<<"/"<<day<<"/"<<year<<" is magic!";
  42. else
  43. cout<<"The date "<<month<<"/"<<day<<"/"<<year<<" is not magic.";
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5276KB
stdin
10
2
25
stdout
Please enter a month in numeric form, no zeros if it is a single digit: 
Please enter a day in numeric form, no zeros if it is a single digit: 
Please enter the last 2 digits of a year: 
The date 10/2/25 is not magic.