Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Make it work please.. #include <iostream> #include <cstdlib> using namespace std

ID: 3787009 • Letter: M

Question

Make it work please..


#include <iostream> #include <cstdlib> using namespace std;
int main() { int month= 0; int day= 0; int year= 0; cin >> month >> day >> year; if (month<1 || month> 12) { cout << " /t*** Month must be between 1 and 12*** "; exit (0); }    if (day < 1 || day > 31) { cout << ' *** Day must be between 1 and 31 *** ": exit (0); } if (year < 1 || year > 99) { cout << " *** Year must be between 1 and 99 *** "; exit(0); }    if (month * day == year) cout " "<< month << "/" << day << "/" << year << "is a magic date ";    else cout " "<< month << "/" << day << "/" << year << "is not a magic date "; }
#include <iostream> #include <cstdlib> using namespace std;
int main() { int month= 0; int day= 0; int year= 0; cin >> month >> day >> year; if (month<1 || month> 12) { cout << " /t*** Month must be between 1 and 12*** "; exit (0); }    if (day < 1 || day > 31) { cout << ' *** Day must be between 1 and 31 *** ": exit (0); } if (year < 1 || year > 99) { cout << " *** Year must be between 1 and 99 *** "; exit(0); }    if (month * day == year) cout " "<< month << "/" << day << "/" << year << "is a magic date ";    else cout " "<< month << "/" << day << "/" << year << "is not a magic date "; } Lab 03 Problem Statement Magic Dates The date June 10, 1960 is an example of a so called ma date since when written gic with numbers as mm/ddlyy or dd/mmy, the month times the day equals the year. Write a program that asks the user to enter a month [1-12), a day [1-31], and a two- digit year [1-99]. The program should determine whether the month times the day is equal to the year. If so, it should display a message saying the date is magic. Otherwise, it should display a message saying the date is not magic. All user-entered data must be validated, displaying appropriate messages for out-of-range data items. Source: Gaddis, Tony. Starting out with Javo-From Control Structures through Obyects. Upper Saddle River, NJ: Pearson Education, 2013, print. Hints: I. Think of the appropriate data type(s) to use 2. Try using arithmetic expressions within conditions, for instance, (month day year) 3. Use compound condition with logical operators- validate data-entries to

Explanation / Answer

Hi,

I have modifid the code and fixed all compile issues and highlighted the code changes below.

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
int month= 0;
int day= 0;
int year= 0;
cin >> month >> day >> year;
if (month<1 || month> 12)
{
cout << " /t*** Month must be between 1 and 12*** ";
return 0;
}
  
if (day < 1 || day > 31)
{
cout << " *** Day must be between 1 and 31 *** ";
return 0;
}

if (year < 1 || year > 99)
{
cout << " *** Year must be between 1 and 99 *** ";
return 0;
}
  
if (month * day == year)
cout<< " "<< month << "/" << day << "/" << year << "is a magic date ";
  
else
cout<< " "<< month << "/" << day << "/" << year << "is not a magic date ";
return 0;
  

}
  

Output:

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                              

sh-4.2$ main                                                                                                                                                                                                                                           

06 10 1960                                                                                                                                                                                                                                             

                                                                                                                                                                                                                                                       

        *** Year must be between 1 and 99 ***                                                                                                                                                                                                          

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                              

sh-4.2$ main                                                                                                                                                                                                                                           

06 10 60                                                                                                                                                                                                                                               

                                                                                                                                                                                                                                                       

        6/10/60is a magic date

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote