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

Using C++, write a program that inputs a date in MM DD YY form and outputs the d

ID: 3569173 • Letter: U

Question

Using C++, write a program that inputs a date in MM DD YY form and outputs the day of the week that corresponds to that date. Classes must be used to encapsulate the date. Use private member variables to store the day, month, and year along with an appropriate constructor and member functions to get and set the data. Create a public function that returns the day of the week. All helper functions should be declared private. The program should have functions to: determine if the date falls on a leap year, what century the date falls on, the month of the year, and the year on which the date falls. Thank you very much.

Explanation / Answer

#include <iostream>
   using namespace std;
  
  
   class date
   {
   //private:
   int month;
   int day;
   int year;
   public:
   date (int month = 1, int day = 1, int year = 2001)
   {
   date::month = month;
   date::day = day;
   date::year = year;
   };
   void showDate2();
   void showDate();
   ~date(){}
  
   };
  
   void date::showDate(){
   cout << month << "/" << day << "/" << year << endl;
   }
   void date::showDate2(){
   string
monthName[12] = {"January","February","March","April","May","June","July",
   "August","September","October","November","December"};
   cout << monthName[month-1] << day << "," << year << endl;
   }
   int main()
   {
   int month;
   int day;
   int year;
   string monthName[12];
   cout << "enter month (between 1 and 12)" << endl;
   cin >> month;
   while (month > 12 || month < 1)
}  
   cout << "please enter a valid month";
   cin >> month;
   }
   cout << "enter day (between 1 and 31)" << endl;
   cin >> day;
  
   while (day > 31 || day < 1)
   {
   cout << "please enter a valid day";
   cin >> day;
   }
  
  
   cout << "enter year (between 1900 and 2010)"<< endl;
   cin >> year;
  
   while (year > 2010 || year < 1900)
   {
   cout << "please enter a valid year";
   cin >> year;
   }
  
  
  
   date newDate(month, day, year);
   newDate.showDate();
   date newDate2(monthName, day, year);
   newDate2.showDate2();
   system ("PAUSE");
   return 0;
   }
  

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