[nfbcs] C++ Assignment Help

Jim Barbour jbar at barcore.com
Fri Oct 27 16:05:35 UTC 2017


You should play with the offset variable and see if you get the hang
of it.

offset is a variable that describes where in the week you want to
start the calendar on.  0 for Sunday, 1 for Monday, etc.

However, you want the input to be 0 for monday, 1 for Tuesday, and 6 for sunday.

Since you want 0 to mean Monday, instead of Sunday (which is the beginning of the week), you want to input N, and have it set to N+1 and wrap to 0 if you input 6.

Modulo math is when you have a number that just keeps looping between 0 and n (n = 6 is this case)  This code..

   int i = 0;
   while (1)
   {
      cout << i;
      i++;
      i %= 7;
   }

will just keep printing the numbers 0 through 6 over and over again.

This should get you going.

Jim

On Fri, Oct 27, 2017 at 02:45:36AM -0500, Lanie Molinar via nfbcs wrote:
> Wow, thanks! That fixed it! I understand if it's too hard to explain, but
> why did that change anything? I want to understand so maybe I can avoid this
> problem in the future.
> 
> 
> On 10/27/2017 2:36 AM, Jim Barbour wrote:
> > Leave the count at 0, and add these two lines right after the open
> > brace of the displayTable function..
> > 
> > Basically, you need to increment the offset by 1 and set it back to 0
> > if the offset is 7.  This makes the calendar start on Monday.
> > 
> >     offset++;
> >     offset%=7;
> > 
> > Jim
> > 
> > On Fri, Oct 27, 2017 at 02:12:29AM -0500, Lanie Molinar via nfbcs wrote:
> > > I think that just made things worse. Take a look at the attached log now.
> > > 
> > > 
> > > On 10/27/2017 2:06 AM, Jim Barbour wrote:
> > > > So, one thing you should do is start with
> > > > 
> > > > int count = 0;
> > > > 
> > > > instead of
> > > > 
> > > > int count = 1;
> > > > 
> > > > I think that will fix you up.
> > > > 
> > > > Jim
> > > > 
> > > > On Fri, Oct 27, 2017 at 01:34:01AM -0500, Lanie Molinar via nfbcs wrote:
> > > > > Hi, everyone. Thanks for trying to help me a couple days ago. I still didn't
> > > > > understand what I needed to do after you tried to help, but not long after
> > > > > that, I was able to find a tutor, and she helped me a lot. Now, I have a
> > > > > question about another assignment, and I think this one even has my tutor
> > > > > stuck. I'm working on a program that prompts a user for the number of days
> > > > > in the month and the offset from Monday for that month, and then displays a
> > > > > calendar table. It's a lot like the calendar I wrote the pseudocode for in
> > > > > the assignment before this. It's almost complete, but the spacing of the
> > > > > numbers in the first row is off by 4, and I don't know how to fix it. I've
> > > > > tried several things, and my tutor has suggested some things, too, but
> > > > > nothing fixes it. My professor says this is probably the hardest assignment
> > > > > of the semester, and I can definitely see why. Can you please take a look at
> > > > > my work and let me know if you have any suggestions? I'm attaching my work,
> > > > > my log from PuTTY that shows the expected output, and the assignment
> > > > > instructions. Thanks.
> 
> 
> _______________________________________________
> nfbcs mailing list
> nfbcs at nfbnet.org
> http://nfbnet.org/mailman/listinfo/nfbcs_nfbnet.org
> To unsubscribe, change your list options or get your account info for nfbcs:
> http://nfbnet.org/mailman/options/nfbcs_nfbnet.org/jbar%40barcore.com
> 




More information about the NFBCS mailing list