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

CALENDAR SCHEDULING REQUIREMENTS: A certain charity recruits twelve volunteers e

ID: 3819623 • Letter: C

Question

CALENDAR SCHEDULING REQUIREMENTS: A certain charity recruits twelve volunteers each year to spearhead its fundraising efforts. Each volunteer is assigned one month to take the lead organizing events. As these are volunteers, the charity does it best to accommodate everyone's schedule as much as possible. Before the year begins, each volunteer is asked to give his or her top three choices for a month to serve. These preferences are likely to overlap. For example: John Mary Susan March December first choice December May March second choice February April February April third choice obviously both Susan and John cannot be assigned December, one of them will need to be assigned a different month. The best possible assignment for the three volunteers (ignoring the other nine for the moment) would be Mary March John December Susan February as John and Mary get their first choice and Susan receives her second. For twelve volunteers, the task above is humanly unmanageable, and so the charity has contacted you to automate this process for them The charity proposes that the following point system be used when determining the desirability of a particular month assignment to its volunteers: for each volunteer assigned his or her first choice 3 points for each volunteer assigned his or her second choice 2 points for each volunteer assigned his or her third choice 1 point for each volunteer not assigned any of his or her choices 0 points Thus, each of the 12! possible assignments of months to volunteers will have a desirability between 0 and 3 Your task is to find the best calendar assignment. SPECIFICATIONS Design and implement a program to find the best possible calendar assignment for the charity's volunteers. Your authored code MUST be a client of the UnsortedTvpe class presented in lecture.

Explanation / Answer

#include "Cal.h"

Calendar :: Calendar (int _month, int _year){

   month = _month;
   year = _year;
}

void Calendar :: setFirstDay(){
//This part determines which day will be the first day of that year (0 for Sunday, 1 for Monday, etc.)
   int day=1;
   int y = year - (14-month)/12;
   int m = month +12 * ((14-month) / 12) -2;
   firstday= (day + y + y / 4 - y / 100 + y / 400 + (31 * m / 12)) % 7;
}

void Calendar :: print(){

   int NumberOfDaysInMonth;
   int FirstDayOfMonth = 0;
   int DayOfWeekCounter = 0;
   int DateCounter = 1;

   switch (month)
   {
   case 1:
       cout<<setw(21)<<"January "<<year;
       NumberOfDaysInMonth = 31;
   break;
   case 2:
       cout<<setw(21)<<"February "<<year;
       if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
       NumberOfDaysInMonth = 29;
       else
       NumberOfDaysInMonth = 28;
   break;
   case 3:
       cout<<setw(21)<<"March "<<year;
       NumberOfDaysInMonth = 31;
   break;
   case 4:
       cout<<setw(21)<<"April "<<year;
       NumberOfDaysInMonth = 30;
   break;
   case 5:
       cout<<setw(21)<<"May "<<year;
       NumberOfDaysInMonth = 31;
   break;
   case 6:
       cout<<setw(21)<<"June "<<year;
       NumberOfDaysInMonth = 30;
   break;
   case 7:
       cout<<setw(21)<<"July "<<year;
       NumberOfDaysInMonth = 31;
   break;
   case 8:
       cout<<setw(21)<<"August "<<year;
       NumberOfDaysInMonth = 31;
   break;
   case 9:
       cout<<setw(21)<<"September "<<year;
       NumberOfDaysInMonth = 30;
   break;
   case 10:
       cout<<setw(21)<<"October "<<year;
       NumberOfDaysInMonth = 31;
   break;
   case 11:
       cout<<setw(21)<<"November "<<year;
       NumberOfDaysInMonth = 30;
   break;
   case 12:
       cout<<setw(21)<<"December "<<year;
       NumberOfDaysInMonth = 31;
   break;
   }

//Display the days at the top of each month

   cout<<" Sun Mon Tue Wed Thu Fri Sat";
   cout<<" "<<setw(2);

//Determine where the first day begins

   for (FirstDayOfMonth; FirstDayOfMonth < firstday; ++FirstDayOfMonth)
   {

       cout<<setw(6);
   }

   int tempfirstday=firstday;
   DateCounter = 1;
   DayOfWeekCounter = tempfirstday;
//This loop represents the date display and will continue to run until
//the number of days in that month have been reached
   for (DateCounter; DateCounter <= NumberOfDaysInMonth; ++DateCounter)
   {
       cout<<DateCounter<<setw(6);
       ++DayOfWeekCounter;
       if (DayOfWeekCounter > 6)
       {
           cout<<" "<<setw(2);
           DayOfWeekCounter = 0;
       }
   }
   cout << " " ;

   tempfirstday = DayOfWeekCounter + 1;
}

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