Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Moonphase calculation

Posted on 2005-03-09
5
Medium Priority
?
1,072 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
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

Technology Partners: 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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
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 opening and reading files in the C programming language.
Suggested Courses

572 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