Saturday, November 30, 2002

current mp3: sleep together - garbage

eh. wow. i'm really starting to hate this history packet. it's 60 pages of reading. blech. so i did the reading but the trouble is i don't get any credit unless i answer the questions. bloody hell. you mean i have to go back through the packet?!

i've been working on my website and i'm already bored. and i wonder why i never put up websites.

but now i think i'll go through my program for comp sci and figure out what's wrong with it. it's supposed to output a calendar for the year. here, i'll even put up what i have so far, just for your especial enjoyment:

// this program is supposed to take the year
// and the day of the week of jan. 1, and print
// a calendar for the year

#include <iostream>
#include <string>    // for stuff using strings
#include <iomanip>   // for formatting

using namespace std;

void Calendar (int, int, string, int&);

int main()
{
   int day;
   int year;

   int jan = 31;
   int feb = 28;
   int mar = 31;
   int apr = 30;
   int may = 31;
   int jun = 30;
   int jul = 31;
   int aug = 31;
   int sep = 30;
   int oct = 31;
   int nov = 30;
   int dec = 31;

   int nextday;

   cout << "What day of the week is January 1st on? (1 for Sunday, 2 for Monday, etc.) ";
   cin >> day;

   cout << "What year is it? ";
   cin >> year;

   if ( (year % 4) == 0 )
      feb++;

   Calendar (jan, day, "January", nextday);
   Calendar (feb, nextday, "February", nextday);
   Calendar (mar, nextday, "March", nextday);
   Calendar (apr, nextday, "April", nextday);
   Calendar (may, nextday, "May", nextday);
   Calendar (jun, nextday, "June", nextday);
   Calendar (jul, nextday, "July", nextday);
   Calendar (aug, nextday, "August", nextday);
   Calendar (sep, nextday, "September", nextday);
   Calendar (oct, nextday, "October", nextday);
   Calendar (nov, nextday, "November", nextday);
   Calendar (dec, nextday, "December", nextday);

   return 0;
}

void Calendar (int num, int day, string month, int& nextday)
{
   cout << month << endl;
   cout << "----------" << endl;
   cout << " S  M  T  W  T  F  S " << endl;

   int count = 1;

   while (num >= count)
   {
      // placeholders:
      if (day == 7)
         cout << "  .  .  .  .  .  . "; // six day spaces
      else if (day == 6)
         cout << "  .  .  .  .  . "; // five day spaces
      else if (day == 5)
         cout << "  .  .  .  . "; // four day spaces
      else if (day == 4)
         cout << "  .  .  . "; // three day spaces
      else if (day == 3)
         cout << "  .  . "; // two day spaces
      else if (day == 2)
         cout << "  . "; // one day space

      while (day <= 7 && num >= count)
      {
         cout << setw(2) << count << " ";
         count++;
         day++;
      }

      if (num < count)
      {
         if (day <= 7)
            nextday = day;
         else if (day == 8)
            nextday = 1;
      }

      cout << endl;
      day = 1;
   }

   cout << endl;
}

oh, wait... um, i already found a bug and fixed it. but yeah. so, maybe it works now. aargh. it's ok, at least i found an error. and if anybody else finds another error, then hey! that's even better. i guess.

eh. anyways...