Program designed to calcuate #of days between date

Please help me with this program. It is supposed to determine the number of days between two dates inputted by the user while also taking into account leap years. This program also has to do error checking. It must include at least "if" statement, at least 2 function, at least 1 loop structure, at least 1 switch statement. This is what I have so far but I am completely lost.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;

int main()
{
 	int day, month, date;

	
     cin >> month;
		   do
		       {
cout <<"\nPlease enter your birthday in the following format: MM-DD-YYY" << endl << endl;
             //totally lost on this part
		   	 	  cin >> month;
		   	 	  cin.get(ch);
		   	 	  cin >> date;
		   	 	  cin.get(ch)
		   	 	  cin >> year;
		   	 	  cout << endl;
		   	 	  
		       } while ((month <= 12) || (month >= 1));
	 			  
	 			   cout <<"Please enter a valid date" << endl;
	 			      
	 			 cin.get(ch);
	 			 
	 			 cin >> day;
 			      if ((day < 31) || (day >1))
 			      else 
 			      	   cout <<"Please enter a valid date" << endl;
	 			 cin.get(ch);
	 			 cin >> year;
	 			 
	 			 
	 			 //not really sure what this does..
    system("pause");
    return 0;

}



This is as far as I've gotten. Please, please help me with this.
Last edited on
If this is not a classroom or homework assignment, you'll find it much easier to do if you get a library for Julian dates. You convert each date to Julian (or Modified Julian) format and then subtract.

If this is for an assignment, you may want to begin my counting the full years and then adding days for each partial year. Loop through each full year and if year % 4 == 0, leapyearcount++. A partial year may or may not include Feb. 29th even if it is a leap year, so leapyearcount++ only if needed. For partial years, add the full months first and then remaining days.
Topic archived. No new replies allowed.