program c++ print calender HELP

Discussion in 'C++' started by programmer c++, Jan 15, 2009.

Thread Status:
Not open for further replies.
  1. programmer c++

    programmer c++ New Member

    Joined:
    Jan 15, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    hey
    this program print calender can some body help me to complete
    please

    Code: Cpp

    Code:
    #include <iostream>
    #include <iomanip>
    using namespace std;
    //do not modify data types and consts
    enum weekDay {Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday};
    const enum weekDay d01y01m1430  = Monday;
    const char *weekDayStr[] = {"Sa", "Su", "Mo", "Tu", "We", "Th", "Fr"};
    const char *monthStr[] = {"Muharram", "Safar", "Rabi' Al-Awwal", "Rabi' Al-Akhir", "Jumada Al-Awwal", "Jumada Al-Akhir", "Rajab", "Sha'aban", "Ramadan", "Shawwal", "Dhu Al-Qi'da", "Dhu Al-Hijjah"};
    const int nDaysPerMonth1430[] = {29, 30, 30, 29, 29, 30, 29, 30, 29, 30, 29, 30};
    const int WEEKS = 5; // 5 weeks a month
    const int DAYS = 7;// 7 days a week
    const int MONTHS = 12; // 12 months a year
    
    // do not modify menu
    int menu() {
      int op;
      int m;
      do {
        m = 1;
        cout <<setfill('*')<<setw(80)<<'*'<<endl;
        cout <<'*'<<setfill(' ')<<setw(4)<<' '<<setw(66)<<left<<"Display Year" <<right<<setw(5)<<m++<<setw(4)<<'*'<<endl;
        cout <<'*'<<setfill(' ')<<setw(4)<<' '<<setw(66)<<left<<"Display Month" <<right<<setw(5)<<m++<<setw(4)<<'*'<<endl;
        cout <<'*'<<setfill(' ')<<setw(4)<<' '<<setw(66)<<left<<"Display Week" <<right<<setw(5)<<m++<<setw(4)<<'*'<<endl;
        cout <<'*'<<setfill(' ')<<setw(4)<<' '<<setw(66)<<left<<"Display Day" <<right<<setw(5)<<m++<<setw(4)<<'*'<<endl;
        cout <<'*'<<setfill(' ')<<setw(4)<<' '<<setw(66)<<left<<"Exit" <<right<<setw(5)<<m++<<setw(4)<<'*'<<endl;
        cout <<setfill('*')<<setw(80)<<'*'<<endl;
        cout<<setfill(' ');
        cin >> op;
      } while (op < 1 || op >= m);
      return op;
    }
     
    void fillDays(int days[WEEKS][DAYS][MONTHS]) { 
      // add code here
    }
    void displayYear(const int days[WEEKS][DAYS][MONTHS], int monthsPerRow) {
      // add code here
    }
    void displayMonth(int days[WEEKS][DAYS][MONTHS], int month) {
      // add code here
    }
    void displayWeek(int days[WEEKS][DAYS][MONTHS], int month, int week) {
      // add code here
    }
    void displayDay(int days[WEEKS][DAYS][MONTHS], int month, int day) {
      // add code here
    }
    // do not modify main
    int main() {
      int days[WEEKS][DAYS][MONTHS] = {{{0}}};
      int monthsPerRow = 1;
      int month;
      int week;
      int day;
      fillDays(days);
      do {
        int op = menu();
        switch (op) {
          case 1:
            cout <<"Display Year:"<<endl;
            do {
              cout <<"monthsPerRow (1-3) = ";
              cin >> monthsPerRow;
            } while (monthsPerRow < 0 || monthsPerRow > 3);
            displayYear(days, monthsPerRow);
            break;
          case 2:
            cout <<"Display Month"<<endl;
            do {
              cout <<"month (1-12) = ";
              cin >> month;
            } while (month < 1 || monthsPerRow > 12);
            displayMonth(days, month);
            break;
          case 3:
            cout <<"Display Week:"<<endl;
            do {
              cout <<"month (1-12) = ";
              cin >> month;
            } while (month < 1 || month > 12);
            do {
              cout <<"week (1-5) = ";
              cin >> week;
            } while (week < 1 || week > 5);
            displayWeek(days, month, week);
            break;
          case 4:
            cout <<"Display Day:"<<endl;
            do {
              cout <<"month (1-12) = ";
              cin >> month;
            } while (month < 1 || month > 12);
            do {
              cout <<"day (1-"<<nDaysPerMonth1430[month-1]<<") = ";
              cin >> day;
            } while (day < 1 || day > nDaysPerMonth1430[month-1]);
            displayDay(days, month, day);
            break;
          default:
            cout <<"Exit"<<endl;
            exit(0);
        }
      } while (1);
      return 0;
    }
     


    the print of program is in the attach files

    thank you
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice