Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,332 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,098 people online right now. Registration is fast and FREE... Join Now!




input date, month, and year, then display the week and day

 
Reply to this topicStart new topic

input date, month, and year, then display the week and day, teach me

jakee
post 10 Mar, 2008 - 02:52 AM
Post #1


New D.I.C Head

*
Joined: 21 Feb, 2008
Posts: 9


My Contributions


hello!!

thanks for those people who reply to my previous post. i hope you can still help me.:-) can you please write a code about inputing the date, month, year, and display the week and day. and the if the user input three zero's. it will display already the result.

for example:

input:

31 02 2000

23 01 2001

13 12 2003

0 0 0

output:
monday 234

wednesday 231

saturday 132

just show me some codes and i'll understand it..

thanks!
User is offlineProfile CardPM

Go to the top of the page

NickDMax
post 10 Mar, 2008 - 11:24 AM
Post #2


2B||!2B

Group Icon
Joined: 18 Feb, 2007
Posts: 2,857



Thanked 47 times

Dream Kudos: 550
My Contributions


Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: code.gif

Thanks.
User is offlineProfile CardPM

Go to the top of the page

captainhampton
post 10 Mar, 2008 - 11:53 AM
Post #3


Jawsome++;

Group Icon
Joined: 17 Oct, 2007
Posts: 518



Thanked 2 times

Dream Kudos: 825
My Contributions


Do you have anything that you have attempted to at least try? Post some attempts at this material and we will be more than willing to help you out.
User is offlineProfile CardPM

Go to the top of the page

jakee
post 10 Mar, 2008 - 05:54 PM
Post #4


New D.I.C Head

*
Joined: 21 Feb, 2008
Posts: 9


My Contributions


CODE
#include<iostream>
#include<cstdlib>
using namespace std;


int Calendar;

int dd, mm, yy;

int main()
{

    do
    {
        cout << "Enter Day: " << endl;
        cin >> dd;
        cout << "Enter Month: " << endl;
        cin >> mm;
        cout << "Enter Year: " << endl;
        cin >> yy;

    }
    while(dd > 0 && mm > 0 && yy > 0);

    return 0;
}


this is the code i made but it is incomplete. i do not know the formula in getting the number of days and the day itself.
User is offlineProfile CardPM

Go to the top of the page

zmikeb
post 10 Mar, 2008 - 07:25 PM
Post #5


New D.I.C Head

*
Joined: 1 Mar, 2008
Posts: 27

here's a start:
CODE
    int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
    if( yy / 4 == 0 )
        months[1] = 29;
User is offlineProfile CardPM

Go to the top of the page

jakee
post 11 Mar, 2008 - 05:52 PM
Post #6


New D.I.C Head

*
Joined: 21 Feb, 2008
Posts: 9


My Contributions


QUOTE(zmikeb @ 10 Mar, 2008 - 08:25 PM) *

here's a start:
CODE
    int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
    if( yy / 4 == 0 )
        months[1] = 29;



can you please explain to me. thanks!
User is offlineProfile CardPM

Go to the top of the page

zmikeb
post 11 Mar, 2008 - 07:07 PM
Post #7


New D.I.C Head

*
Joined: 1 Mar, 2008
Posts: 27

well, this is just the declaration of an array that holds the days of each month of the year.....if it is a leapyear, february has 29 days.
User is offlineProfile CardPM

Go to the top of the page

zmikeb
post 11 Mar, 2008 - 07:12 PM
Post #8


New D.I.C Head

*
Joined: 1 Mar, 2008
Posts: 27

CODE
#include<iostream>
#include<cstdlib>
using namespace std;


int calendar;

int dd, mm, a = 0;
int yy;

int main()
{


        cout << "Enter Day (dd, **, ****): " << endl;
        cin >> dd;
        cout << "Enter Month (**, mm, ****): " << endl;
        cin >> mm;
        cout << "Enter Year (**, **, yyyy): " << endl;
        cin >> yy;

    int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    if( yy % 4 == 0 )
        months[1] = 29;
    for( int i = mm-1; i > 0; i-- )
    {
        a += months[i-1];
    }
    cout << a + dd; //outputs the day of the year

    return 0;
}


This shows the day of the year it is. Thats all I'm helping you with. Besides, I dont know how to show the day of the week...
User is offlineProfile CardPM

Go to the top of the page

jakee
post 12 Mar, 2008 - 05:35 PM
Post #9


New D.I.C Head

*
Joined: 21 Feb, 2008
Posts: 9


My Contributions


QUOTE(zmikeb @ 11 Mar, 2008 - 08:12 PM) *

CODE
#include<iostream>
#include<cstdlib>
using namespace std;


int calendar;

int dd, mm, a = 0;
int yy;

int main()
{


        cout << "Enter Day (dd, **, ****): " << endl;
        cin >> dd;
        cout << "Enter Month (**, mm, ****): " << endl;
        cin >> mm;
        cout << "Enter Year (**, **, yyyy): " << endl;
        cin >> yy;

    int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    if( yy % 4 == 0 )
        months[1] = 29;
    for( int i = mm-1; i > 0; i-- )
    {
        a += months[i-1];
    }
    cout << a + dd; //outputs the day of the year

    return 0;
}


This shows the day of the year it is. Thats all I'm helping you with. Besides, I dont know how to show the day of the week...


can you please refer to my code.

CODE
#include<iostream>
#include<cstdlib>
using namespace std;


int DetermineDayWeek(int, int, int);

int dd, mm, yy, a = 0;
int main()
{
    do
    {
        cout << "Enter Day: " << endl;
        cin >> dd;
        cout << "Enter Month: " << endl;
        cin >> mm;
        cout << "Enter Year: " << endl;
        cin >> yy;

    }
    while(dd > 0 && mm > 0 && yy > 0);
    if(dd == 0 && mm == 0 && yy == 0)
    {
        DetermineDayWeek(dd, mm, yy);
    }
    return 0;
}

int DetermineDayWeek(int dd, int mm, int yy)
{
    
    int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    
    if( yy % 4 == 0 )
    {
        months[1] = 29;
    }

    for(int i = mm-1; i > 0; i--)
    {
        a += months[i-1];
    }
    cout << a + dd << endl;
    return 0;
}


thanks!
User is offlineProfile CardPM

Go to the top of the page

zmikeb
post 12 Mar, 2008 - 07:02 PM
Post #10


New D.I.C Head

*
Joined: 1 Mar, 2008
Posts: 27

looks good so far. As for the day of the week, I suggest you look it up on google. They have really great explanations on how to do it.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 03:17AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month