GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 29-Oct-2006, 18:54
killer9012 killer9012 is offline
Member
 
Join Date: Mar 2004
Posts: 137
killer9012 is an unknown quantity at this point

Date


I would like to make a program that will read dates under the formate dd mm yy and output it to gregorian style : day of the week, month dd yyyy. Program must be able to read dates from a file as far back as january1 1990, or 01 01 1990 to today, and must use the 2 following function files:

CPP / C++ / C Code:
#include <iostream.h>


enum oneDay { monday=1, tuesday, wednesday, thursday, friday, saturday, sunday } ;


oneDay Successor( oneDay day )
{
	
	if( day == sunday)
		return monday ;
	else
        return oneDay(   int(day) + 1 ) ;
}

oneDay Predecessor( oneDay day)
{
	if( day == monday )
		return sunday ;
	else
		return oneDay(   int(day) - 1 ) ;

}


int Intconverter( oneDay internalday )
{
	// internaly :		1 == monday, 2 == tuesday, 3 == wednesday, ..., 7 == sunday.
	return  int(internalday) ;
	// users :	1 == monday, 2 == tuesday, 3 == wednesday, ..., 7 == sunday.
}

oneDay convertIntto_oneDay( int dayuser )
{
	// users :	1 == monday, 2 == tuesday, 3 == wednesday, ..., 7 == sunday.
	return  oneDay( dayuser  ) ;
	// internaly :		1 == monday, 2 == tuesday, 3 == wednesday, ..., 7 == sunday.
}



void   showday( oneDay date )
{
	switch( date )
	{
	case monday : 
			cout << "monday" ;
			break ;
	case tuesday :
			cout << "tuesday" ;
			break ;
	case wednesday :
			cout << "wednesday" ;
			break ;
	case thursday :
			cout << "thursday" ;
			break ;
	case friday :
			cout << "friday" ;
			break ;
	case saturday :
			cout << "saturday" ;
			break ;
	case sunday :
			cout << "sunday" ;
	}
}


CPP / C++ / C Code:
#include <iostream.h>


enum oneMonth {	january=1,	february,	march,		april,		may,		june, 
				july,	august,		september,	october,	november,	december
			} ;



oneMonth Successor( oneMonth month )
{
	if( month == december )
		return january ;
	else	
		return oneMonth(   int(month) + 1 ) ;
}


oneMonth Predecessor( oneMonth month )
{
	if( month == january )
		return december ;
	else
		return oneMonth(   int(month) - 1 ) ;
}


int Intconverter( oneMonth monthInternal )
{
	// Internal :		1 == january, 2 == february, 3 == march, ..., 12 == december.
	return  int(monthInternal) ;
	// Users :	1 == january, 2 == february, 3 == march, ..., 12 == december.
}


oneMonth ConvertIntto_oneMonth( int MonthUser )
{
	// Users :	1 == january, 2 == february, 3 == march, ..., 12 == december.
	return  oneMonth( monthUser  ) ;
	// Internal :		1 == january, 2 == february, 3 == march, ..., 12 == december.
}




void   showmonth( oneMonth monthnumber )
{
	switch( monthnumber )
	{
	case january : 
			cout << "january" ;
			break ;
	case february :
			cout << "february" ;
			break ;
	case march :
			cout << "march" ;
			break ;
	case april :
			cout << "april" ;
			break ;
	case may :
			cout << "may" ;
			break ;
	case june :
			cout << "june" ;
			break ;
	case july :
			cout << "july" ;
			break ;
	case august :
			cout << "august" ;
			break ;
	case september :
			cout << "september" ;
			break ;
	case october :
			cout << "october" ;
			break ;
	case november :
			cout << "november" ;
			break ;
	case december :
			cout << "december" ;
	}
}



Problem is im not really sure how to incoperate it. I know how to read data from a file, then these programs will work on it, and then i can output the results, but how to get the to work is where i get stuck.
  #2  
Old 30-Oct-2006, 16:12
killer9012 killer9012 is offline
Member
 
Join Date: Mar 2004
Posts: 137
killer9012 is an unknown quantity at this point

Re: Date


is it impossible, no one knows for sure, no one cares (lol)??
  #3  
Old 30-Oct-2006, 18:14
Sokar Sokar is offline
Member
 
Join Date: May 2005
Posts: 243
Sokar has a spectacular aura aboutSokar has a spectacular aura about

Re: Date


Quote:
Originally Posted by killer9012
is it impossible,
Not sure. I did not look that close at the code.

Quote:
Originally Posted by killer9012
no one knows for sure,
Someone knows.

Quote:
Originally Posted by killer9012
no one cares (lol)??
ha!
Yes that is it.

I would say forget the file stuff for now. Start by picking one part of the date. Say the month. In your Example of "01 01 1990" it would be 1. So that is entered as an int. Now just look for the function that will convert an "int" to a type "oneMonth". So you are looking for a function that takes an int as a argument/parameter and returns a type "oneMonth". Do you see one that does that(oneMonth ConvertIntto_oneMonth( int MonthUser )? Write the code for main so that works/gives the results you want then move onto the next part you want to get working.
ect ect ...
  #4  
Old 31-Oct-2006, 09:21
killer9012 killer9012 is offline
Member
 
Join Date: Mar 2004
Posts: 137
killer9012 is an unknown quantity at this point

Re: Date


what i wasnt sure how to do is call a function from the.h file.
  #5  
Old 31-Oct-2006, 09:34
killer9012 killer9012 is offline
Member
 
Join Date: Mar 2004
Posts: 137
killer9012 is an unknown quantity at this point

Re: Date


CPP / C++ / C Code:
#include <iostream>
#include <fstream>
#include <oneMonth.h>

using std::cout;
using std::cin;
using std::endl;

int date;

int main()
{
	cout << "enter a number of month (1-12) : " ;
	cin >> date;

	return 0;



}

error, cant find file oneMonth.h.... its in the same directory....
  #6  
Old 31-Oct-2006, 09:37
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,310
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Date


Quote:
Originally Posted by killer9012
CPP / C++ / C Code:

#include <oneMonth.h>


error, cant find file oneMonth.h.... its in the same directory....

That notation tells the compiler to look in its installation directories for the header. The easiest way to tell the compiler to look into the same directory (where the source file is), is to use

CPP / C++ / C Code:
#include "oneMonth.h"

Regards,

Dave
  #7  
Old 31-Oct-2006, 09:39
killer9012 killer9012 is offline
Member
 
Join Date: Mar 2004
Posts: 137
killer9012 is an unknown quantity at this point

Re: Date


haha thanks bro!
  #8  
Old 31-Oct-2006, 09:41
killer9012 killer9012 is offline
Member
 
Join Date: Mar 2004
Posts: 137
killer9012 is an unknown quantity at this point

Re: Date


ughh... i get the following errors for my oneMonth file

c:\documents and settings\eah8340\mes documents\udm\automne 2006\info1001\labos_info1001\devoir_06\1\onemonth. h(39) : error C2065: 'monthUser' : undeclared identifier
C:\Documents and Settings\eah8340\Mes documents\udm\Automne 2006\INFO1001\Labos_INFO1001\Devoir_06\1\date.cpp( 5) : error C2874: using-declaration causes a multiple declaration of 'cout'
d:\program files\microsoft visual studio\vc98\include\iostream(1 : see declaration of 'cout'
C:\Documents and Settings\eah8340\Mes documents\udm\Automne 2006\INFO1001\Labos_INFO1001\Devoir_06\1\date.cpp( 6) : error C2874: using-declaration causes a multiple declaration of 'cin'
d:\program files\microsoft visual studio\vc98\include\iostream(17) : see declaration of 'cin'
  #9  
Old 31-Oct-2006, 09:49
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,310
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Date


Quote:
Originally Posted by killer9012
ughh... i get the following errors for my oneMonth file

c:\documents and settings\eah8340\mes documents\udm\automne 2006\info1001\labos_info1001\devoir_06\1\onemonth. h(39) : error C2065: 'monthUser' : undeclared identifier
.
.
.


At least it found the file, and that's a Good Thing, right?

However...

Showing us the error messages that came from onemonth.h without showing us what's in the file is not likely to be productive. Post the code.

Regards,

Dave
  #10  
Old 31-Oct-2006, 12:19
killer9012 killer9012 is offline
Member
 
Join Date: Mar 2004
Posts: 137
killer9012 is an unknown quantity at this point

Re: Date


the code from onemonth and oneday are posted in my first post all the way up top
 
 

Recent GIDBlogInstall Adobe Flash - Without Administrator Rights by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Overloaded Constructors and Class within Class jdbrine C++ Forum 2 10-Jul-2006 22:14
Current Date (Short Date) In C Vishy80 C Programming Language 2 07-Jun-2005 13:54
Limit combo box and date time picker choice according to database created in folder shinyhui C++ Forum 0 22-Feb-2005 20:16
Limit combo box and date time picker choice according to database created in folder shinyhui MS Visual C++ / MFC Forum 0 22-Feb-2005 02:13
Rookie problem with date format cave monkey MySQL / PHP Forum 4 18-Mar-2004 08:41

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:35.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.