I need help on how to write a program that determines the number of days between two dates input by the user...u have to use at leat one loop structure and i dont know where to start...can someone please help me...i have the input by the user down i jus need help with the loops.. thx

can you post that code? i dont know y you need the loop...

My instructor says its mandatory..i guess to see if we know how to do it, im tryin to figure out how i could use it..btw its C++.
Must have:
at least one if statement = i did that
at least one switch statement = i did that
at least one loop structure = confused on how to use that one
at least 2 functions value returning r void = i have an idea on that one

any help is appreciated :)

Reread chandra.rajat's post and do what he said.

Its kinda long but here it is...

// Program assignment #1
// Brandon Moffett

#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

// function prototypes

int main()
{
    
    int mm,dd,yy,mm2,dd2,yy2,maxdays,day;
    char s,s2;
//prompt the user for input
cout << "Please input your birthday using this format (MM-DD-YYYY)\n";
cin >> mm;
cin.get(s);
cin >> dd;
cin.get(s);
cin >> yy;
cout << "Please input the current date using this format (MM-DD-YYYY)\n";
cin >> mm2;
cin.get(s2);
cin >> dd2;
cin.get(s2);
cin >> yy2;

  switch (mm)
     {
     case 1: maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 3:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 5:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 7:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 8:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 10:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 12:  maxdays = 31;
          if (dd <= maxdays)
                 cout << "Dates are acceptional, please continue...\n";
               else 
                    cout << "Invalid day of the month : " << dd << endl;
                                      
                break;
    case 4:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 6:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 9:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 11:  maxdays = 30; 
         if (dd <= maxdays)
                 cout << "Dates are acceptional, please continue...\n";
               else
                   cout << "Invalid day of the month : " << dd << endl;
                                    
                break;
    case 2: maxdays = 29;
         if ( yy%4 == 0)
        { dd <= maxdays;}
                   else
                       dd <= 28;
                       break;
 
     default:
             cout << "Invalid month : " << mm << endl;
             break;
             }

       switch (mm2)
     {
     case 1: maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 3:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 5:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 7:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 8:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 10:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 12:  maxdays = 31;
          if (dd2 <= maxdays)
                 cout << "Dates are acceptional, please continue...\n";
               else 
                    cout << "Invalid day of the month : " << dd << endl;
                                      
                break;
    case 4:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 6:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 9:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 11:  maxdays = 30; 
         if (dd2 <= maxdays)
                 cout << "Dates are acceptional, please continue...\n";
               else
                   cout << "Invalid day of the month : " << dd << endl;
                                    
                break;
    case 2: maxdays = 29;
         if ( yy%4 == 0)
        { dd2 <= maxdays;}
                   else
                       dd <= 28;
                       break;
 
     default:
             cout << "Invalid month : " << mm << endl;
             break;
             }   

  
system("pause");
return 0;
}

I was going to have the switch statements value returning functions

Since your post is unreadable, please read the Rules as requested when you signed up, the post titled Read Me: Read This Before Posting (the title says it all), and don't ignore the words on the background of the box you entered your post into.

Its kinda long but here it is...

// Program assignment #1
// Brandon Moffett

#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

// function prototypes

int main()
{
    
    int mm,dd,yy,mm2,dd2,yy2,maxdays,day;
    char s,s2;
//prompt the user for input
cout << "Please input your birthday using this format (MM-DD-YYYY)\n";
cin >> mm;
cin.get(s);
cin >> dd;
cin.get(s);
cin >> yy;
cout << "Please input the current date using this format (MM-DD-YYYY)\n";
cin >> mm2;
cin.get(s2);
cin >> dd2;
cin.get(s2);
cin >> yy2;

  switch (mm)
     {
     case 1: maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 3:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 5:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 7:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 8:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 10:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 12:  maxdays = 31;
          if (dd <= maxdays)
                 cout << "Dates are acceptional, please continue...\n";
               else 
                    cout << "Invalid day of the month : " << dd << endl;
                                      
                break;
    case 4:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 6:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 9:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 11:  maxdays = 30; 
         if (dd <= maxdays)
                 cout << "Dates are acceptional, please continue...\n";
               else
                   cout << "Invalid day of the month : " << dd << endl;
                                    
                break;
    case 2: maxdays = 29;
         if ( yy%4 == 0)
        { dd <= maxdays;}
                   else
                       dd <= 28;
                       break;
 
     default:
             cout << "Invalid month : " << mm << endl;
             break;
             }

       switch (mm2)
     {
     case 1: maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 3:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 5:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 7:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 8:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 10:maxdays = 31;
          if (dd <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
     case 12:  maxdays = 31;
          if (dd2 <= maxdays)
                 cout << "Dates are acceptional, please continue...\n";
               else 
                    cout << "Invalid day of the month : " << dd << endl;
                                      
                break;
    case 4:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 6:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 9:maxdays = 31;
          if (dd2 <= maxdays)
             cout << "Dates are acceptional, please continue...\n";
             else
                 cout << "Invalid day of the month : " << dd << endl;
                 break;
    case 11:  maxdays = 30; 
         if (dd2 <= maxdays)
                 cout << "Dates are acceptional, please continue...\n";
               else
                   cout << "Invalid day of the month : " << dd << endl;
                                    
                break;
    case 2: maxdays = 29;
         if ( yy%4 == 0)
        { dd2 <= maxdays;}
                   else
                       dd <= 28;
                       break;
 
     default:
             cout << "Invalid month : " << mm << endl;
             break;
             }   

  
system("pause");
return 0;
}

I was going to have the switch statements value returning functions

To start with you can club the conditions that have the same number of days so ur code will become a lot more compact.

for ex

case 1:
case 3:
case 5:
//

and then the statements and break;

second your formula to check leap year is not absolutely correct. for example year 1800 is divisible by 4 but is not a leap year. you have to check if a year is divisible by 4 and not divisible by 100 then its a leap year or if the year is evenly divisible by 100 and 400. so that logic needs to be changed.

OK i fixed all of that thx.Any ideas about the loop situation?

i wrote an if statement for the leap year..
if( yy%4 == 0 && yy%100 != 0)

the correct condition is

if((yy%4 == 0) && !(yy%100 ==0) || (yy%400 == 0))

probably you can have a while loop to keep taking inputs and returning the number of days till the user says i'm done.

so all your code can be put inside a while loop and you can ask the user if he wants to continue or not.