Hello there,
Okay i had to write a program that computes the number of days between two dates, right, and so far i'm just sort of stumped over what to do next to get it all right and functioning correctly. I've written the code and everything else, and It runs, but the awnsers not what i'm looking for. Maybe someone can tell me what i'm not doing that i need to be doing. Well i would appreciate your help.
Here's my source code:
// Program 7
// This program computes the number of days between two dates.
#include <iostream>
using namespace std;
int DayCalculation (int month, int day, int year, int month2, int day2, int year2);
int main()
{
int month;
int secondMonth;
int year;
int day;
int secondYear;
int secondDay;
cout << "Enter first dates month ";
cin >> month;
cout << "Enter second dates month ";
cin >> secondMonth;
cout << "Enter the first dates day ";
cin >> day;
cout << "Enter the second dates day ";
cin >> secondDay;
cout << "Enter the first dates year ";
cin >> year;
cout << "Enter the second dates year ";
cin >> secondYear;
if (month >= 10 && day >= 15 && year >= 1582)
cout << "The date you entered is invalid";
else
DayCalculation ( month, day, year, secondMonth, secondDay,secondYear);
return 0;
}
int DayCalculation ( int month, int day, int year, int month2, int day2, int year2)
{
int result1 = 0;
int result2;
int result3;
long JulianDayNumber;
if (month == 1 || month == 2 )
{
year--;
month = month +12;
}
result1 = 2- year/100+year / 400; // test each one to make sure the right number.
result2 = int(365.25 * year);
result3 = int(30.6001 * (month + 1));
JulianDayNumber = result1 + result2 + result3 + day + 1720994.5;
cout << JulianDayNumber << endl;
return 0;
}