Hi There,

I need assistance with the assert function. The question is convert a date to Julian date and then check which one is the smallest and subtract to show the different days. That is all done. The part I have no idea is how to use the assert function to verify that the dates entered are legitimate dates.

Is there someone that can assist me please.

```
//Converting date to Julian format
#include <iostream>
#include <assert.h>
using namespace std;
//definition for the number of days in
//each month
int daysPerMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int calcJulian(int dd, int mm)
{
int t = 0;
int numDays;
for (int i = 1; i < mm; i++)
{
switch(i)
{
case 1: numDays = daysPerMonth[0];
case 3: numDays = daysPerMonth[2];
case 5: numDays = daysPerMonth[4];
case 7: numDays = daysPerMonth[6];
case 8: numDays = daysPerMonth[7];
case 10: numDays = daysPerMonth[9];
case 12: numDays = daysPerMonth[11];
t += 31;
break;
case 4: numDays = daysPerMonth[3];
case 6: numDays = daysPerMonth[5];
case 9: numDays = daysPerMonth[8];
case 11: numDays = daysPerMonth[10];
t += 30;
break;
case 2: numDays = daysPerMonth[1];
t += 28;
break;
}
}
t += dd;
return t;
}
int main()
{
int dd, mm;
cout << "Enter day (dd)" << endl;
cin >> dd;
cout << "Enter month (mm)" << endl;
cin >> mm;
int f = calcJulian(dd, mm);
int dd2, mm2;
cout << "Enter day (dd)" << endl;
cin >> dd2;
cout << "Enter month (mm)" << endl;
cin >> mm2;
int g = calcJulian(dd2, mm2);
cout << "Julian day: " << f << endl;
cout << "Julian day: " << g << endl;
//check which is the smaller date and then subtract
//to get the different between the days
float ans;
if ( f < g ) {
ans = (g-f);
}
else {
ans =(f-g);
}
cout << "Numbers of days different between the two days is: " << ans << endl;
system("PAUSE");
return 0;
}
```