December 10, 2013, 11:49:31 PM
 News: Welcome!
 Forum Home Help Search Forum Login Register
Pages: [1]   Go Down
 Send this topic  |  Print
sopian_87
Newbie

Posts: 2

 « on: May 15, 2010, 05:23:51 PM »

when is calculate manually using calculator 365.25 x 2009 = 733787.25
but when in c++ the answer is 12891. why it be like tat and how i can get answer using c++ is 733787.25 .......pls help me
 Logged
Jenna Hall
Full Member

Posts: 155

 « Reply #1 on: May 16, 2010, 08:45:34 PM »

 Logged
sopian_87
Newbie

Posts: 2

 « Reply #2 on: May 17, 2010, 10:40:22 AM »

#include <math.h>
#include <iostream.h>

main()
{

int dd,mm,yyyy,mmN,yyyyN,B,A,C,D,Cc;
char cal;
const double pi = 3.1415926535897932384626433832795 ;
double JD;

cout << "\n Date of Observation [ddmmyyyy]:  ";
cin  >>  dd >> mm >> yyyy;

if ( dd >= 15 && mm >= 10 && yyyy >= 1582 ) goto cal;

cal:
if (mm <= 2)
{
yyyyN = yyyy - 1;
mmN = mm + 12;

cout << "\n\n yyyy'= " << yyyyN;
cout << "\n\n mm'= " << mmN;

A = yyyyN / 100;
B = 2 - A + (A/4);
cout << "\n A = " << A;
cout << "\n B = " << B;
C = 365.25 * yyyyN  ;
cout << "\n C = " << C;
D = 30.6001 * ( mmN + 1 );
cout << "\n D = " << D;
JD = B + C + D + dd + 1720994.5;
cout << "\n JD = " << JD;
}

return 0;
}
 Logged
Haitam
Newbie

Posts: 16

 « Reply #3 on: July 10, 2011, 04:12:16 AM »

you have to change the C and  D Parameters type you are using them as integers and integers can not contain Float numbers...
 Logged
Pages: [1]   Go Up
 Send this topic  |  Print