[nfbcs] [program-l] Re: Help with Calendar Project.

Lanie Molinar laniemolinar91 at gmail.com
Mon Oct 30 05:28:48 UTC 2017


Hi. I got some help from a tutor and was able to fix most of the issues, 
but for some reason, I'm still failing test 7. I think I'm pretty close 
to fixing it, but even though I'm putting an if statement with the new 
line that fixes that issue before my for loop in the display table, I'm 
getting a bunch of extra spaces between the end of the header and the 
new line that's being outputted. Take a look at my attached log and my 
revised code and you'll see what I mean. Any ideas on how to fix this? 
Thanks.


On 10/29/2017 4:23 PM, William Grussenmeyer wrote:
> it looks like this might be the problem for at least the example of jan  1753:
> int computeOffset(int month, int year)
> {
>     int numDays = numDaysInYear(year);
>
> should be    int numDays = 0;
>
> Here you are adding the days of 1753 before the loop.  this then will
> give you the days offset for year 1754 which is why you are off by 1
> day.
> as for your oct 2017 error you are off by 2 days, giving you oct 2019.
> Not sure why but try fixing the above problem first and try again.
>
>
> On 10/29/17, Lanie Molinar <laniemolinar91 at gmail.com> wrote:
>> Hi, everyone. I'm sending this again with a modified PuTTY log since I
>> got a message saying my email was too large to send to program-l. If you
>> don't mind, I need your help again. I'm working on a major C++ project
>> that puts a lot of what I've learned over the past few weeks together.
>> It asks the user for the month and year and then displays a calendar,
>> kind of like the assignment I did the other day. I think I almost have
>> it, but for some reason, some of the tests my school's testbed system
>> does are showing a bunch of blank lines instead of the expected output,
>> and I have no idea why. Other tests work fine, but then there are a few
>> that don't. I know there are a few other things that I still need to
>> correct, but I'm trying to fix this issue first. Can you please take a
>> look at my code and my log from PuTTY and help me understand what I
>> could be doing wrong? Thanks.
>>
>>
>

-------------- next part --------------
/***********************************************************************
* Program:
*    Project 07, Calendar
*    Sister Unsicker, CS124
* Author:
*    Lanie Molinar
* Summary: 
*    This program gets the month and year from the user and then uses that 
*    data to display a calendar.
*
*    Estimated:  5.0 hrs   
*    Actual:     6.0 hrs
*      At first, I tried to creat the displayTable functionby using my 
*      pseudocode from project 6, without using or looking at the table I 
*      creatd in assignment 25. I ended up having to rethink that strategy 
*      when i got bad results from doing that, I plugged in the function from
*      assignment 25 and everything worked perfectly.
************************************************************************/

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

/***********************************************************************
* This function prompts the user for the month, making sure it's between 1 and 
* 12,  and then returns it to main().
***********************************************************************/
int getMonth()
{
   int month;
   cout << "Enter a month number: ";
   cin >> month;
   while (month < 1 || month > 12)
   {
      cout << "Month must be between 1 and 12.\n";
      cin >> month;
   }
   return month;
}

/***********************************************************************
* This function prompts the user for the year, making sure it's within an 
* acceptable range, and then returns it to main().
***********************************************************************/
int getYear()
{
   int year;
   cout << "Enter year: ";
   cin >> year;
   cout << endl;
   while (year < 1753)
   {
      cout << "Year must be greater than or equal to 1753.\n";
      cin >> year;
   }
   return year;
}

/***********************************************************************
* This function determines whether the year entered by the user is a leap 
* year.
***********************************************************************/
bool isLeapYear(int year)
{
   if ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)))
      return true;
   else
      return false;
}

/***********************************************************************
* This function determines how many days are in a given year, calling 
* isLeapYear() to help it do so.
***********************************************************************/
int numDaysInYear(int year)
{
   int numDays;
   bool isLeap = isLeapYear(year);
   if (isLeap == true)
      numDays = 366;
   else
      numDays = 365;
   return numDays;
}

/***********************************************************************
* This function determines the number of days in a given month, calling 
* isLeapYear() to help it do so.
***********************************************************************/
int numDaysInMonth(int month, int year)
{
   int numDays;
   if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || 
   month == 10 || month == 12)
      numDays = 31;
   else if (month == 2)
      numDays = 28 + isLeapYear(year);
   else if (month == 4 || month == 6 || month == 9 || month == 11)
      numDays = 30;
   return numDays;
}

/***********************************************************************
*This function computes the offset from Monday for the given month.
***********************************************************************/
int computeOffset(int month, int year)
{
   int numDays = 0;
   for (int startMonth = 1; startMonth < month; startMonth++)
      numDays += numDaysInMonth(startMonth, year);
   for (int startYear = 1753; startYear < year; startYear++)
      numDays += numDaysInYear(startYear);
   int offset = (numDays % 7);
   return offset;
}

/***********************************************************************
* This function displays the header for the calendar table.
***********************************************************************/
void displayHeader(int month, int year)
{
   if (month == 1)
      cout << "January, ";
   else if (month == 2)
      cout << "February, ";
   else if (month == 3)
      cout << "March, ";
   else if (month == 4)
      cout << "April, ";
   else if (month == 5)
      cout << "May, ";
   else if (month == 6)
      cout << "June, ";
   else if (month == 7)
      cout << "July, ";
   else if (month == 8)
      cout << "August, ";
   else if (month == 9)
      cout << "September, ";
   else if (month == 10)
      cout << "October, ";
   else if (month == 11)
      cout << "November, ";
   else
      cout << "December, ";
   cout << year << endl;
   cout << "  Su  Mo  Tu  We  Th  Fr  Sa";
}

/***********************************************************************
* This function displays the calendar table.
***********************************************************************/
void displayTable(int offset, int numDays)
{
   offset++;
   if (offset != 7)
      cout << "\n";
   int count = 0;
   for (int day = 1; day <= numDays; )
   {
      if (offset > 0)
      {
         cout << "    ";
         offset--;
      }
      else if (offset == 0)
      {
         cout << setw(4) << day;
         day++;
      }
      count++;
      if ((count % 7 == 0) && (day != (numDays + 1)) || (day > numDays))
         cout << endl;
   }
}

/***********************************************************************
* This function calls the functions that display the calendar header an table.
***********************************************************************/
void display(int month, int year, int offset)
{
   displayHeader(month, year);
   int numDays = numDaysInMonth(month, year);
   displayTable(offset, numDays);
}

/**********************************************************************
*    The main function calls many of the other functions in this program.
***********************************************************************/
int main()
{
   int month =getMonth();
   int year = getYear();
   int offset = computeOffset(month, year);
   display(month, year, offset);
   return 0;
}
-------------- next part --------------
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2017.10.29 06:53:07 =~=~=~=~=~=~=~=~=~=~=~=
Using username "living4god1991".
living4god1991 at 157.201.194.201's password: 
Last login: Sun Oct 29 05:27:22 2017 from 67.44.193.75

[living4god1991 at LinuxLab01 ~]$ a.outg++ project07.cppa.outtestpBed pcs124/project07.cpp [project07.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Trivial case; January 1st, 1753 is a Monday. Here the offset is 0

   > Enter a month number: 1
   > Enter year: 1753
   > 
   > January, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >        1   2   3   4   5   6
   >    7   8   9  10  11  12  13
   >   14  15  16  17  18  19  20
   >   21  22  23  24  25  26  27
   >   28  29  30  31

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

February 1st, 1753 is 31 days away from January 1st.

   > Enter a month number: 2
   > Enter year: 1753
   > 
   > February, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28

Test 2 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

February 1753 is not a leap year so there are 28 days,

   > Enter a month number: 3
   > Enter year: 1753
   > 
   > March, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 3 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This test is to make sure that the correct number of days for each month
is in the program.

   > Enter a month number: 12
   > Enter year: 1753
   > 
   > December, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28  29
   >   30  31

Test 4 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This test is to check add years when leap years are not involved

   > Enter a month number: 1
   > Enter year: 1755
   > 
   > January, 1755
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                1   2   3   4
   >    5   6   7   8   9  10  11
   >   12  13  14  15  16  17  18
   >   19  20  21  22  23  24  25
   >   26  27  28  29  30  31

Test 5 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 6

Even though 1756 is a leap year, we should not count 356 days when
adding the days for the month. It only counts after the 28th of February, 1756

   > Enter a month number: 1
   > Enter year: 1756
   > 
   > January, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 6 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 7

Leap year

   > Enter a month number: 2
   > Enter year: 1756
   > 
   > February, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >    1   2   3   4   5   6   7
   >    8   9  10  11  12  13  14
   >   15  16  17  18  19  20  21
   >   22  23  24  25  26  27  28
   >   29

Test 7 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 8

Not a leap year

   > Enter a month number: 2
   > Enter year: 1800
   > 
   > February, 1800
   >   Su  Mo  Tu  We  Th  Fr  Sa
   > \n                            
Exp:                            1\n
   > \n                            
Exp:    2   3   4   5   6   7   8\n
   > \n                            
Exp:    9  10  11  12  13  14  15\n
   > \n                            
Exp:   16  17  18  19  20  21  22\n
   > \n                        
Exp:   23  24  25  26  27  28\n
   > \n
Exp: No output
Timed out!

[living4god1991 at LinuxLab01 ~]$ Using username "living4god1991".
living4god1991 at 157.201.194.201's password: 
Last login: Sun Oct 29 05:53:26 2017 from 67.44.193.75

[living4god1991 at LinuxLab01 ~]$ testBed cs124/project07 project07.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Trivial case; January 1st, 1753 is a Monday. Here the offset is 0

   > Enter a month number: 1
   > Enter year: 1753
   > 
   > January, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >        1   2   3   4   5   6
   >    7   8   9  10  11  12  13
   >   14  15  16  17  18  19  20
   >   21  22  23  24  25  26  27
   >   28  29  30  31

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

February 1st, 1753 is 31 days away from January 1st.

   > Enter a month number: 2
   > Enter year: 1753
   > 
   > February, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28

Test 2 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

February 1753 is not a leap year so there are 28 days,

   > Enter a month number: 3
   > Enter year: 1753
   > 
   > March, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 3 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This test is to make sure that the correct number of days for each month
is in the program.

   > Enter a month number: 12
   > Enter year: 1753
   > 
   > December, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28  29
   >   30  31

Test 4 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This test is to check add years when leap years are not involved

   > Enter a month number: 1
   > Enter year: 1755
   > 
   > January, 1755
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                1   2   3   4
   >    5   6   7   8   9  10  11
   >   12  13  14  15  16  17  18
   >   19  20  21  22  23  24  25
   >   26  27  28  29  30  31

Test 5 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 6

Even though 1756 is a leap year, we should not count 356 days when
adding the days for the month. It only counts after the 28th of February, 1756

   > Enter a month number: 1
   > Enter year: 1756
   > 
   > January, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 6 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 7

Leap year

   > Enter a month number: 2
   > Enter year: 1756
   > 
   > February, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                             \n
Exp:    1   2   3   4   5   6   7\n
   >    1   2   3   4   5   6   7\n
Exp:    8   9  10  11  12  13  14\n
   >    8   9  10  11  12  13  14\n
Exp:   15  16  17  18  19  20  21\n
   >   15  16  17  18  19  20  21\n
Exp:   22  23  24  25  26  27  28\n
   >   22  23  24  25  26  27  28\n
Exp:   29\n
   >   29\n
Exp: No output

Test 7 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 8

Not a leap year

   > Enter a month number: 2
   > Enter year: 1800
   > 
   > February, 1800
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28

Test 8 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 9

Leap year

   > Enter a month number: 2
   > Enter year: 2000
   > 
   > February, 2000
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >            1   2   3   4   5
   >    6   7   8   9  10  11  12
   >   13  14  15  16  17  18  19
   >   20  21  22  23  24  25  26
   >   27  28  29

Test 9 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 10

Your program should be able to handle invalid input for days and for years.
In this case, it should simply re-prompt the user for valid data.

   > Enter a month number: 13
   > Month must be between 1 and 12.
Timed out!

[living4god1991 at LinuxLab01 ~]$ testBed assigncs124/assign25 assignment25.cpp

a.out:

------------------------------------------------------------
Starting Test 1

This first test is the simplest case. Here the offset from Monday
is zero so we start on Monday

   > Number of days: 28
   > Offset: 0
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >        1   2   3   4   5   6
   >    7   8   9  10  11  12  13
   >   14  15  16  17  18  19  20
   >   21  22  23  24  25  26  27
   >   28

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

This is another simple case. The offset from Monday is 3 so
the first day of the month must be Thursday.

   > Number of days: 30
   > Offset: 3
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30

Test 2 passed.
------------------------------------------------------------

Here we will be testing the case when the offset is 6. A common
mistake is to have a blank line at the beginning of the calendar.
In order to get around this, you need a special condition (an IF statement)
that checks for offset == 6 and handle that case.

------------------------------------------------------------
Starting Test 3

   > Number of days: 31
   > Offset: 6
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >    1   2   3   4   5   6   7
   >    8   9  10  11  12  13  14
   >   15  16  17  18  19  20  21
   >   22  23  24  25  26  27  28
   >   29  30  31

Test 3 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

Here is another special case. Since the last day of the month also happens
to be the last day of the week, it is a common case to put an extra blank
line in the output. In other words, you put a newline in the output when
the day of the week is Saturday, and you put a newline in the output when
we get to the end of the month. You will need a special condition to check
that you are not on a Saturday when you display the end of the month newline

   > Number of days: 30
   > Offset: 4
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                        1   2
   >    3   4   5   6   7   8   9
   >   10  11  12  13  14  15  16
   >   17  18  19  20  21  22  23
   >   24  25  26  27  28  29  30

Test 4 passed.
------------------------------------------------------------


============================================================
Passed all tests with no errors.
============================================================

[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign25 assignment25.cpp

a.out:

------------------------------------------------------------
Starting Test 1

This first test is the simplest case. Here the offset from Monday
is zero so we start on Monday

   > Number of days: 28
   > Offset: 0
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >        1   2   3   4   5   6
   >    7   8   9  10  11  12  13
   >   14  15  16  17  18  19  20
   >   21  22  23  24  25  26  27
   >   28

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

This is another simple case. The offset from Monday is 3 so
the first day of the month must be Thursday.

   > Number of days: 30
   > Offset: 3
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30

Test 2 passed.
------------------------------------------------------------

Here we will be testing the case when the offset is 6. A common
mistake is to have a blank line at the beginning of the calendar.
In order to get around this, you need a special condition (an IF statement)
that checks for offset == 6 and handle that case.

------------------------------------------------------------
Starting Test 3

   > Number of days: 31
   > Offset: 6
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >    1   2   3   4   5   6   7
   >    8   9  10  11  12  13  14
   >   15  16  17  18  19  20  21
   >   22  23  24  25  26  27  28
   >   29  30  31

Test 3 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

Here is another special case. Since the last day of the month also happens
to be the last day of the week, it is a common case to put an extra blank
line in the output. In other words, you put a newline in the output when
the day of the week is Saturday, and you put a newline in the output when
we get to the end of the month. You will need a special condition to check
that you are not on a Saturday when you display the end of the month newline

   > Number of days: 30
   > Offset: 4
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                        1   2
   >    3   4   5   6   7   8   9
   >   10  11  12  13  14  15  16
   >   17  18  19  20  21  22  23
   >   24  25  26  27  28  29  30

Test 4 passed.
------------------------------------------------------------


============================================================
Passed all tests with no errors.
============================================================

[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign25 assignment25.cppproject07 project07.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Trivial case; January 1st, 1753 is a Monday. Here the offset is 0

   > Enter a month number: 1
   > Enter year: 1753
   > 
   > January, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   > \n                            
Exp:        1   2   3   4   5   6\n
   > \n                            
Exp:    7   8   9  10  11  12  13\n
   > \n                            
Exp:   14  15  16  17  18  19  20\n
   > \n                            
Exp:   21  22  23  24  25  26  27\n
   > \n                
Exp:   28  29  30  31\n
   > \n
Exp: No output
Timed out!

[living4god1991 at LinuxLab01 ~]$ testBed cs124/project07 project07.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Trivial case; January 1st, 1753 is a Monday. Here the offset is 0

   > Enter a month number: 1
   > Enter year: 1753
   > 
   > January, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   > \n                            
Exp:        1   2   3   4   5   6\n
   > \n                            
Exp:    7   8   9  10  11  12  13\n
   > \n                            
Exp:   14  15  16  17  18  19  20\n
   > \n                            
Exp:   21  22  23  24  25  26  27\n
   > \n                
Exp:   28  29  30  31\n
   > \n
Exp: No output
Timed out!

[living4god1991 at LinuxLab01 ~]$ testBed cs124/project07 project07.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Trivial case; January 1st, 1753 is a Monday. Here the offset is 0

   > Enter a month number: 1
   > Enter year: 1753
   > 
   > January, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >        1   2   3   4   5   6
   >    7   8   9  10  11  12  13
   >   14  15  16  17  18  19  20
   >   21  22  23  24  25  26  27
   >   28  29  30  31

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

February 1st, 1753 is 31 days away from January 1st.

   > Enter a month number: 2
   > Enter year: 1753
   > 
   > February, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28

Test 2 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

February 1753 is not a leap year so there are 28 days,

   > Enter a month number: 3
   > Enter year: 1753
   > 
   > March, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 3 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This test is to make sure that the correct number of days for each month
is in the program.

   > Enter a month number: 12
   > Enter year: 1753
   > 
   > December, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28  29
   >   30  31

Test 4 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This test is to check add years when leap years are not involved

   > Enter a month number: 1
   > Enter year: 1755
   > 
   > January, 1755
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                1   2   3   4
   >    5   6   7   8   9  10  11
   >   12  13  14  15  16  17  18
   >   19  20  21  22  23  24  25
   >   26  27  28  29  30  31

Test 5 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 6

Even though 1756 is a leap year, we should not count 356 days when
adding the days for the month. It only counts after the 28th of February, 1756

   > Enter a month number: 1
   > Enter year: 1756
   > 
   > January, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 6 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 7

Leap year

   > Enter a month number: 2
   > Enter year: 1756
   > 
   > February, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa                            \n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    1   2   3   4   5   6   7
   >    8   9  10  11  12  13  14
   >   15  16  17  18  19  20  21
   >   22  23  24  25  26  27  28
   >   29

Test 7 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 8

Not a leap year

   > Enter a month number: 2
   > Enter year: 1800
   > 
   > February, 1800
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28

Test 8 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 9

Leap year

   > Enter a month number: 2
   > Enter year: 2000
   > 
   > February, 2000
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >            1   2   3   4   5
   >    6   7   8   9  10  11  12
   >   13  14  15  16  17  18  19
   >   20  21  22  23  24  25  26
   >   27  28  29

Test 9 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 10

Your program should be able to handle invalid input for days and for years.
In this case, it should simply re-prompt the user for valid data.

   > Enter a month number: 13
   > Month must be between 1 and 12.
Timed out!

[living4god1991 at LinuxLab01 ~]$ testBed cs124/project07 project07.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Trivial case; January 1st, 1753 is a Monday. Here the offset is 0

   > Enter a month number: 1
   > Enter year: 1753
   > 
   > January, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >        1   2   3   4   5   6
   >    7   8   9  10  11  12  13
   >   14  15  16  17  18  19  20
   >   21  22  23  24  25  26  27
   >   28  29  30  31

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

February 1st, 1753 is 31 days away from January 1st.

   > Enter a month number: 2
   > Enter year: 1753
   > 
   > February, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28

Test 2 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

February 1753 is not a leap year so there are 28 days,

   > Enter a month number: 3
   > Enter year: 1753
   > 
   > March, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 3 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This test is to make sure that the correct number of days for each month
is in the program.

   > Enter a month number: 12
   > Enter year: 1753
   > 
   > December, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28  29
   >   30  31

Test 4 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This test is to check add years when leap years are not involved

   > Enter a month number: 1
   > Enter year: 1755
   > 
   > January, 1755
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                1   2   3   4
   >    5   6   7   8   9  10  11
   >   12  13  14  15  16  17  18
   >   19  20  21  22  23  24  25
   >   26  27  28  29  30  31

Test 5 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 6

Even though 1756 is a leap year, we should not count 356 days when
adding the days for the month. It only counts after the 28th of February, 1756

   > Enter a month number: 1
   > Enter year: 1756
   > 
   > January, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 6 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 7

Leap year

   > Enter a month number: 2
   > Enter year: 1756
   > 
   > February, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa                            \n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    1   2   3   4   5   6   7
   >    8   9  10  11  12  13  14
   >   15  16  17  18  19  20  21
   >   22  23  24  25  26  27  28
   >   29

Test 7 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 8

Not a leap year

   > Enter a month number: 2
   > Enter year: 1800
   > 
   > February, 1800
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28

Test 8 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 9

Leap year

   > Enter a month number: 2
   > Enter year: 2000
   > 
   > February, 2000
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >            1   2   3   4   5
   >    6   7   8   9  10  11  12
   >   13  14  15  16  17  18  19
   >   20  21  22  23  24  25  26
   >   27  28  29

Test 9 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 10

Your program should be able to handle invalid input for days and for years.
In this case, it should simply re-prompt the user for valid data.

   > Enter a month number: 13
   > Month must be between 1 and 12.
Timed out!

[living4god1991 at LinuxLab01 ~]$ testBed cs124/project07 project07.cpp
/tmp/ky3OBLA2G1/project07.cpp: In function void displayTable(int, int):
/tmp/ky3OBLA2G1/project07.cpp:164:13: error: expected primary-expression before if
       else (if offset == 7)
             ^
/tmp/ky3OBLA2G1/project07.cpp:164:13: error: expected ) before if
/tmp/ky3OBLA2G1/project07.cpp:169:7: error: expected ; before else
       else if (offset == 0)
       ^

Error compiling /tmp/ky3OBLA2G1/project07.cpp.
[living4god1991 at LinuxLab01 ~]$ testBed cs124/project07 project07.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Trivial case; January 1st, 1753 is a Monday. Here the offset is 0

   > Enter a month number: 1
   > Enter year: 1753
   > 
   > January, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa       1   2   3   4   5   6\n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    7   8   9  10  11  12  13\n
Exp:        1   2   3   4   5   6\n
   >   14  15  16  17  18  19  20\n
Exp:    7   8   9  10  11  12  13\n
   >   21  22  23  24  25  26  27\n
Exp:   14  15  16  17  18  19  20\n
   >   28  29  30  31\n            
Exp:   21  22  23  24  25  26  27\n
   >                   
Exp:   28  29  30  31\n

Test 1 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

February 1st, 1753 is 31 days away from January 1st.

   > Enter a month number: 2
   > Enter year: 1753
   > 
   > February, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa                   1   2   3\n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    4   5   6   7   8   9  10\n
Exp:                    1   2   3\n
   >   11  12  13  14  15  16  17\n
Exp:    4   5   6   7   8   9  10\n
   >   18  19  20  21  22  23  24\n
Exp:   11  12  13  14  15  16  17\n
   >   25  26  27  28\n            
Exp:   18  19  20  21  22  23  24\n
   >                   
Exp:   25  26  27  28\n

Test 2 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

February 1753 is not a leap year so there are 28 days,

   > Enter a month number: 3
   > Enter year: 1753
   > 
   > March, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa                   1   2   3\n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    4   5   6   7   8   9  10\n
Exp:                    1   2   3\n
   >   11  12  13  14  15  16  17\n
Exp:    4   5   6   7   8   9  10\n
   >   18  19  20  21  22  23  24\n
Exp:   11  12  13  14  15  16  17\n
   >   25  26  27  28  29  30  31\n
Exp:   18  19  20  21  22  23  24\n
   >                               
Exp:   25  26  27  28  29  30  31\n

Test 3 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This test is to make sure that the correct number of days for each month
is in the program.

   > Enter a month number: 12
   > Enter year: 1753
   > 
   > December, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa                           1\n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    2   3   4   5   6   7   8\n
Exp:                            1\n
   >    9  10  11  12  13  14  15\n
Exp:    2   3   4   5   6   7   8\n
   >   16  17  18  19  20  21  22\n
Exp:    9  10  11  12  13  14  15\n
   >   23  24  25  26  27  28  29\n
Exp:   16  17  18  19  20  21  22\n
   >   30  31\n                    
Exp:   23  24  25  26  27  28  29\n
   >           
Exp:   30  31\n

Test 4 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This test is to check add years when leap years are not involved

   > Enter a month number: 1
   > Enter year: 1755
   > 
   > January, 1755
   >   Su  Mo  Tu  We  Th  Fr  Sa               1   2   3   4\n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    5   6   7   8   9  10  11\n
Exp:                1   2   3   4\n
   >   12  13  14  15  16  17  18\n
Exp:    5   6   7   8   9  10  11\n
   >   19  20  21  22  23  24  25\n
Exp:   12  13  14  15  16  17  18\n
   >   26  27  28  29  30  31\n    
Exp:   19  20  21  22  23  24  25\n
   >                           
Exp:   26  27  28  29  30  31\n

Test 5 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 6

Even though 1756 is a leap year, we should not count 356 days when
adding the days for the month. It only counts after the 28th of February, 1756

   > Enter a month number: 1
   > Enter year: 1756
   > 
   > January, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa                   1   2   3\n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    4   5   6   7   8   9  10\n
Exp:                    1   2   3\n
   >   11  12  13  14  15  16  17\n
Exp:    4   5   6   7   8   9  10\n
   >   18  19  20  21  22  23  24\n
Exp:   11  12  13  14  15  16  17\n
   >   25  26  27  28  29  30  31\n
Exp:   18  19  20  21  22  23  24\n
   >                               
Exp:   25  26  27  28  29  30  31\n

Test 6 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 7

Leap year

   > Enter a month number: 2
   > Enter year: 1756
   > 
   > February, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                             \n
Exp:    1   2   3   4   5   6   7\n
   >    1   2   3   4   5   6   7\n
Exp:    8   9  10  11  12  13  14\n
   >    8   9  10  11  12  13  14\n
Exp:   15  16  17  18  19  20  21\n
   >   15  16  17  18  19  20  21\n
Exp:   22  23  24  25  26  27  28\n
   >   22  23  24  25  26  27  28\n
Exp:   29\n
   >   29\n
Exp: No output

Test 7 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 8

Not a leap year

   > Enter a month number: 2
   > Enter year: 1800
   > 
   > February, 1800
   >   Su  Mo  Tu  We  Th  Fr  Sa                           1\n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    2   3   4   5   6   7   8\n
Exp:                            1\n
   >    9  10  11  12  13  14  15\n
Exp:    2   3   4   5   6   7   8\n
   >   16  17  18  19  20  21  22\n
Exp:    9  10  11  12  13  14  15\n
   >   23  24  25  26  27  28\n    
Exp:   16  17  18  19  20  21  22\n
   >                           
Exp:   23  24  25  26  27  28\n

Test 8 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 9

Leap year

   > Enter a month number: 2
   > Enter year: 2000
   > 
   > February, 2000
   >   Su  Mo  Tu  We  Th  Fr  Sa           1   2   3   4   5\n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    6   7   8   9  10  11  12\n
Exp:            1   2   3   4   5\n
   >   13  14  15  16  17  18  19\n
Exp:    6   7   8   9  10  11  12\n
   >   20  21  22  23  24  25  26\n
Exp:   13  14  15  16  17  18  19\n
   >   27  28  29\n                
Exp:   20  21  22  23  24  25  26\n
   >               
Exp:   27  28  29\n

Test 9 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 10

Your program should be able to handle invalid input for days and for years.
In this case, it should simply re-prompt the user for valid data.

   > Enter a month number: 13
   > Month must be between 1 and 12.
Timed out!

[living4god1991 at LinuxLab01 ~]$ testBed cs124/project07 project07.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Trivial case; January 1st, 1753 is a Monday. Here the offset is 0

   > Enter a month number: 1
   > Enter year: 1753
   > 
   > January, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >        1   2   3   4   5   6
   >    7   8   9  10  11  12  13
   >   14  15  16  17  18  19  20
   >   21  22  23  24  25  26  27
   >   28  29  30  31

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

February 1st, 1753 is 31 days away from January 1st.

   > Enter a month number: 2
   > Enter year: 1753
   > 
   > February, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28

Test 2 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

February 1753 is not a leap year so there are 28 days,

   > Enter a month number: 3
   > Enter year: 1753
   > 
   > March, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 3 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This test is to make sure that the correct number of days for each month
is in the program.

   > Enter a month number: 12
   > Enter year: 1753
   > 
   > December, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28  29
   >   30  31

Test 4 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This test is to check add years when leap years are not involved

   > Enter a month number: 1
   > Enter year: 1755
   > 
   > January, 1755
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                1   2   3   4
   >    5   6   7   8   9  10  11
   >   12  13  14  15  16  17  18
   >   19  20  21  22  23  24  25
   >   26  27  28  29  30  31

Test 5 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 6

Even though 1756 is a leap year, we should not count 356 days when
adding the days for the month. It only counts after the 28th of February, 1756

   > Enter a month number: 1
   > Enter year: 1756
   > 
   > January, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 6 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 7

Leap year

   > Enter a month number: 2
   > Enter year: 1756
   > 
   > February, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa                            \n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    1   2   3   4   5   6   7
   >    8   9  10  11  12  13  14
   >   15  16  17  18  19  20  21
   >   22  23  24  25  26  27  28
   >   29

Test 7 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 8

Not a leap year

   > Enter a month number: 2
   > Enter year: 1800
   > 
   > February, 1800
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28

Test 8 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 9

Leap year

   > Enter a month number: 2
   > Enter year: 2000
   > 
   > February, 2000
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >            1   2   3   4   5
   >    6   7   8   9  10  11  12
   >   13  14  15  16  17  18  19
   >   20  21  22  23  24  25  26
   >   27  28  29

Test 9 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 10

Your program should be able to handle invalid input for days and for years.
In this case, it should simply re-prompt the user for valid data.

   > Enter a month number: 13
   > Month must be between 1 and 12.
Timed out!

[living4god1991 at LinuxLab01 ~]$ testBed cs124/project07 project07.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Trivial case; January 1st, 1753 is a Monday. Here the offset is 0

   > Enter a month number: 1
   > Enter year: 1753
   > 
   > January, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >        1   2   3   4   5   6
   >    7   8   9  10  11  12  13
   >   14  15  16  17  18  19  20
   >   21  22  23  24  25  26  27
   >   28  29  30  31

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

February 1st, 1753 is 31 days away from January 1st.

   > Enter a month number: 2
   > Enter year: 1753
   > 
   > February, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28

Test 2 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

February 1753 is not a leap year so there are 28 days,

   > Enter a month number: 3
   > Enter year: 1753
   > 
   > March, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 3 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This test is to make sure that the correct number of days for each month
is in the program.

   > Enter a month number: 12
   > Enter year: 1753
   > 
   > December, 1753
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28  29
   >   30  31

Test 4 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This test is to check add years when leap years are not involved

   > Enter a month number: 1
   > Enter year: 1755
   > 
   > January, 1755
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                1   2   3   4
   >    5   6   7   8   9  10  11
   >   12  13  14  15  16  17  18
   >   19  20  21  22  23  24  25
   >   26  27  28  29  30  31

Test 5 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 6

Even though 1756 is a leap year, we should not count 356 days when
adding the days for the month. It only counts after the 28th of February, 1756

   > Enter a month number: 1
   > Enter year: 1756
   > 
   > January, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                    1   2   3
   >    4   5   6   7   8   9  10
   >   11  12  13  14  15  16  17
   >   18  19  20  21  22  23  24
   >   25  26  27  28  29  30  31

Test 6 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 7

Leap year

   > Enter a month number: 2
   > Enter year: 1756
   > 
   > February, 1756
   >   Su  Mo  Tu  We  Th  Fr  Sa                            \n
Exp:   Su  Mo  Tu  We  Th  Fr  Sa\n
   >    1   2   3   4   5   6   7
   >    8   9  10  11  12  13  14
   >   15  16  17  18  19  20  21
   >   22  23  24  25  26  27  28
   >   29

Test 7 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 8

Not a leap year

   > Enter a month number: 2
   > Enter year: 1800
   > 
   > February, 1800
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >                            1
   >    2   3   4   5   6   7   8
   >    9  10  11  12  13  14  15
   >   16  17  18  19  20  21  22
   >   23  24  25  26  27  28

Test 8 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 9

Leap year

   > Enter a month number: 2
   > Enter year: 2000
   > 
   > February, 2000
   >   Su  Mo  Tu  We  Th  Fr  Sa
   >            1   2   3   4   5
   >    6   7   8   9  10  11  12
   >   13  14  15  16  17  18  19
   >   20  21  22  23  24  25  26
   >   27  28  29

Test 9 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 10

Your program should be able to handle invalid input for days and for years.
In this case, it should simply re-prompt the user for valid data.

   > Enter a month number: 13
   > Month must be between 1 and 12.
Timed out!

[living4god1991 at LinuxLab01 ~]$ 


More information about the NFBCS mailing list