The Gregorian Calendar

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2005
Posts: 1
Reputation: hmadison1984 is an unknown quantity at this point 
Solved Threads: 0
hmadison1984 hmadison1984 is offline Offline
Newbie Poster

The Gregorian Calendar

 
0
  #1
Sep 9th, 2005
Hi, this is my first time here and I have a problem. I am trying to write a C++ program in Unix that gives me the Gregorian calendar with exceptions to leap year. I have all of my algorithms for calculating days, printing out the months, and such. My problem is that I need a loop in my int main function that loops the input in a way in which it would allow my days and day numbers to sync up and print them in columns and rows.....any suggestions??
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 244
Reputation: Drowzee is an unknown quantity at this point 
Solved Threads: 5
Drowzee Drowzee is offline Offline
Posting Whiz in Training

Re: The Gregorian Calendar

 
0
  #2
Sep 9th, 2005
There's a number of ways to do this. What you're looking for is constant-width columns, correct? For the dates, this isn't too bad, because you just have to do a check based on if the value will be less than ten, and zero/space pad the value in formatting.

For the letters, though, things are a little harder.
Here's just one idea.
You could enumerate the days and months in an order based on the number of letters.
ie,
  1. enum Month{MAY,JUNE,JULY,APRIL,MARCH}; //And so on...
and then use the value of the enumeration to set how many spaces you'll need to format the columns correctly with an if statement.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,445
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1475
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: The Gregorian Calendar

 
0
  #3
Sep 9th, 2005
Another problem will be the fonts used at your terminal. Every terminal may be using a different font set, so the spacing between colums will be diffeent. This app may be a good use for curses library, or use a good GUI library such as QT.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC