?
Solved

Moonphase calculation

Posted on 2005-03-09
5
Medium Priority
?
993 Views
Last Modified: 2010-04-15
To all Wizards...

 I am looking for simple "C" source code for the MoonPhase calculation - going from (in the following order):
  That goes from a (1)new moon > to a (2)new right qtr moon
   > to a (3)new right half moon, > then to a new (4)3/4 qtr
     moon,  > then to a (5)new full moon,  
    then... to a (6)left 3/4 moon, >
    then to a (7)left 1/2 moon, > then to a (8)left qtr moon.  Then it starts over at a new moon.  after the calculations are doing, the function returns a number (1 thru 8), as indicated by the (#).  Return a zero 0 for an error.

 So there you go, can you handle it.  I will make it worth your while points-wise.
0
Comment
Question by:midnightexpress
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 13502475
Ok.   I doubt that this is homework, so....

Source code here:

<Link deleted by sunnycoder, Page Editor>


Kent
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 13504090
midnightexpress,

May we know why you need such source code. I have a suspicion that this could be a coursework assignment.

sunnycoder
0
 
LVL 22

Expert Comment

by:grg99
ID: 13505016
Here's a good hint:  the Moon goes through its phases in a cycle that takes something like 27.33 days (look this up to be sure) .  If you know the date of just ONE full moon,  and the number of days since then, it's a simple matter of mod arithmetic and a division to find the phase.

Or look in Knuth Volume 1.  One of the early homework problems is to calculate the date of Easter, which involves finding the phase of the Moon.


0
 

Author Comment

by:midnightexpress
ID: 13508032
As requested by KDO and SUNNYCODER, here goes:

This is not a homework assignment. This project, that I have been working on, has been going on for the past couple of years.  The project consists of a Windows DLL File that contains many simple "C" routines that deals with dates.  Routines that deals with date conversions from one date format to another date format,  date math, date approximation, calculating easter, daylight savings time, MRP dates, date validation,  date lapse, holidays, retrieving date info(whether in a micro or marco views), and so forth.  As for education and my present occupation?-> I work for the USPS in a craft position and have long since graduated from college with a B.S. degree many many years ago.  And have enjoyed working on this project.  I hope this few sentences have answered your questions. Does this mean more points are required for your help??

  Thanks(TIA),
  Midnighexpress
  Mar 10th, 2005
  RSVP...
 
0
 
LVL 46

Accepted Solution

by:
Kent Olsen earned 660 total points
ID: 13508135

Thanks for the clarification.  We occasaionally get burned by inadvertantly doing homework for posters so we try and be careful.  Your assertion that this is not homework is sufficient.  :)

Here's the link that I first posted.  http://www.voidware.com/moon_phase.htm

Check the source there and see if it is adequate.


Kent

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question