Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 10th, 2004, 2:43 PM   #1
lepricaun
Hobbyist Programmer
 
lepricaun's Avatar
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5 lepricaun is on a distinguished road
Program To Get The Day By Giving Month And Date

hi all,

i was browsing some sites this afternoon and someone needed to write a program for his homework, he posted the complete assignment in the hope someone would do it for him....
Well, i did (i was bored at work).

here it is:

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

*                                         *

* File: day.c                                   *

*                                         *

* Purpose: getting a month and date as input, outputting the day         *

*                                         *  

* Usage: day.exe <month> <date>                          *

*                                         *

* Copyright (C) 2004 Scorpius, scorpius_unknown@yahoo.com, all rights reserved  *

*                                         *

* This program is free software; you can redistribute it and/or          *

* modify it under the terms of the GNU General Public License           *

* as published by the Free Software Foundation; either version 2         *

* of the License, or (at your option) any later version.             *

*                                         *

* This program is distributed in the hope that it will be useful,         *

* but WITHOUT ANY WARRANTY; without even the implied warranty of         *

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          *

* GNU General Public License for more details.                  *

*                                         *

* You should have received a copy of the GNU General Public License        *

* along with this program; if not, write to the Free Software           *

* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.   *

*                                         *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */



#include <stdio.h>

#include <strings.h>



int main(int argc,char *argv[])

{

  /*first arguments checking*/

  if (argc<3)

  {

    printf("Too few arguments, usage: %s <month> <date>",argv[0]);

    return 1;

  }

  if (argc>3)

  {

    printf("Too many arguments, usage: %s <month> <date>",argv[0]);

    return 1;

  }

/*now for the actual program*/

  

  const char *months[]={"jan","feb","mar","apr","may","jun","jul","aug","sep","okt","nov","dec"};

  const char *days[]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};

  const int zero_th[]={2,4,4,6,0,2,3,4,0,1,3,4};

  int day=atoi(argv[2]);

  int i,count=0,int_months=0;

  char buf[strlen(argv[1])];

  strcpy(buf,argv[1]);

  if(buf[3]!='\0')

  {

    printf("Usage: %s <month> <date>",argv[0]);

    return 1;

  }    

  for (i=0;i<12;i++)

  {

    if (strcmp(buf,months[i])==0)

    {

      int_months=i;

      break;

    }

    else

    {

      count++;

    }    

  } 

  if (count>11)

  {

    printf("Unrecognized Month [%s]: use jan, feb, mar, etc",buf);

    return 1;

  }  

  if ((day<1)||(day>31))

  {

     printf("Usage: %s <month> <date>",argv[0]);

    return 1;

  }

  i=((day+int_months+zero_th[int_months])%7);

  printf("%s",days[i]);

  return 0;

}

perhaps it might be usefull to someone , who knows, at least i have another program
__________________
http://www.white-scorpion.nl
lepricaun is offline   Reply With Quote
Old Sep 10th, 2004, 4:01 PM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
<RANT>
I hate students that come in and just post a homework assignment, no attempt at solving it themselves. No effort on there part, I hope they all fail. Because if they cheat their way through school, they'll get a job in the field, if they're lucky, then their incompetence will get them fired.

Besides, there is code to do this particular thing, plastered all around the internet, they probably didn't even bother to use google.
</RANT>

lol..
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Sep 10th, 2004, 4:50 PM   #3
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Yea. I usually try to do all my homework before I ask, no matter what the subject is. Of course there are times where I just get lazy, but I try not to make that a habit. I make sure to do my own homework for computer science, though, my favorite class . I don't mind helping people with their homework when I can, I just feel if they don't do it themselves they are only hurting themselves. I'll help them out, but they won't gain much out of it except the grade.
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Sep 11th, 2004, 2:45 AM   #4
lepricaun
Hobbyist Programmer
 
lepricaun's Avatar
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5 lepricaun is on a distinguished road
well, i don't really care helping them, it's just another experience for me in programming, my biggest problem is thinking about what kind of program i'm going to write, and since it is only 3 months ago since i started programming, i see it as an assignment for me too....

as for the students, well, if they want to get the answer by someone else, let them. they will have to take an exam and nobody is going to be there to help them .

but hey, the reason i posted it is because maybe, someone would find it usefull for some kind of script or something, and since i wrote it myself (although it was not my idea), i don't have to worry about copyright
__________________
http://www.white-scorpion.nl
lepricaun is offline   Reply With Quote
Old Sep 11th, 2004, 11:56 PM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
I have no problems answering questions for students... However, I simply expect them to attempt to solve it on their own work. Effort is required. If they are willing to put forth the effort to learn, they need to change majors, as this industry constantly changes and they will be required to learn new technologies, etc.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Sep 12th, 2004, 3:56 AM   #6
lepricaun
Hobbyist Programmer
 
lepricaun's Avatar
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5 lepricaun is on a distinguished road
Quote:
Originally posted by Infinite Recursion@Sep 12 2004, 04:56 AM
I have no problems answering questions for students... However, I simply expect them to attempt to solve it on their own work. Effort is required. If they are willing to put forth the effort to learn, they need to change majors, as this industry constantly changes and they will be required to learn new technologies, etc.
exaclty!
that's why it is up to themselves, if they are stupid enough to ask questions like that, they WILL fail the exam.
it's their own fault and their own responsibility.
__________________
http://www.white-scorpion.nl
lepricaun is offline   Reply With Quote
Old Mar 2nd, 2005, 6:52 PM   #7
gardon
Programmer
 
Join Date: Dec 2004
Posts: 87
Rep Power: 4 gardon is on a distinguished road
Guys, I'm not a lazy person at all. I always attempt my assignments. However, people aren't looking at the future with their exams and things, because maybe some people are only taking the class for a requirement or a credit or something.

So when someone asks for help, help him or don't help him, but don't bash his reasons for asking for help. There have been a couple times when I have no clue where to start.
gardon is offline   Reply With Quote
Old Mar 2nd, 2005, 7:10 PM   #8
Donald Ferrone
Newbie
 
Donald Ferrone's Avatar
 
Join Date: Mar 2005
Posts: 19
Rep Power: 0 Donald Ferrone is on a distinguished road
Send a message via MSN to Donald Ferrone
I like cheaters; they give me deserving victims to antagonize and to fail.
Donald Ferrone is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:28 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC