CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    13

    Beginner Request help w/ Assignment

    My assignment to convert dates to European Date, Julian Date, Military Date, and Business date is due in 8 hours and I can't figure out how to fix the errors. Upon compiling I get these errors:

    21: Undefined symbol 'GetDatemonth' in function main()
    45: If statement missing ( in function GetDate(int &,int &,int &)
    55: Declaration syntax error in function GetDate(int &, int &, int&)
    221: Declaration missing ; in function GetDate(int &, int &, int &)
    221: Compound statement missing } in function GetDate(int &, int &, int &)

    Here is my code:
    //program to display Eropean Date, Julian Date, Military Date, and Business date formats.

    #include <stdio.h>
    #include <string.h>

    #define TRUE 1
    #define FALSE 0

    int GetDate (int &month, int &day, int &year);
    void Europe (int month, int day, int year);
    void Julian (int month, int day, int year);
    void Military (int month, int day, int year);
    void Business (int month, int day, int year);



    void main (void)
    {
    int month, day, year;
    GetDate (month, day, year);
    while (GetDatemonth > 12)
    {
    printf ("Data entered was invalid!\n");
    printf ("Now go home and think about what you have done!\n");
    break;

    }
    Europe (month, day, year);
    Julian (month, day, year);
    Military (month, day, year);
    Business (month, day, year);


    return;

    }

    int GetDate (int &month, int &day, int &year)

    {
    printf ("Please enter a US date format (mm/dd/yr) \n");
    scanf ("%d/%d/%d" ,&month, &day, &year);
    while(1)
    {
    if {0 < month > 13 && 0 < day > 32 && 0 < year > 100)
    else
    break;
    printf ("Date entered = \t\t\t%d/%d/%d\n" ,month, day, year);
    }
    return 0;
    }


    void Europe (int month, int day, int year)
    {
    printf ("European format =\t\t%d/%d/%d\n", day, month, year);


    return;
    }


    void Julian (int month, int day, int year)
    {
    int days;
    switch (month)
    {
    case 1:
    days =day;
    break;
    case 2:
    days = 31 + day;
    break;
    case 3:
    days = 31 + 28 + day;
    break;
    case 4:
    days = 31 + 28 + 31 + day;
    break;
    case 5:
    days = 31 + 28 + 31 + 30 + day;
    break;
    case 6:
    days = 31 + 28 + 31 + 30 + 31 +day;
    break;
    case 7:
    days = 31 + 28 + 31 + 30 + 31 + 30 + day;
    break;
    case 8:
    days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day;
    break;
    case 9:
    days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day;
    break;
    case 10:
    days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;
    break;
    case 11:
    days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;
    break;
    case 12:
    days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;
    break;
    }

    printf ("Julian format =\t\t\t%d", year);
    if (days >0 && days < 10)
    printf ("00%d", days);
    if (days >=10 && days < 100)
    printf ("0%d", days);
    if (days >=100 && days <= 366)
    printf ("%d", days);

    printf ("\n");
    return;
    }

    void Military (int month, int day, int year)
    {
    char Month[15];
    switch (month)
    {
    case 1:
    strcpy(Month,"JAN");
    break;
    case 2:
    strcpy(Month,"FEB");
    break;
    case 3:
    strcpy(Month,"MAR");
    break;
    case 4:
    strcpy(Month,"APR");
    break;
    case 5:
    strcpy(Month,"MAY");
    break;
    case 6:
    strcpy(Month,"JUN");
    break;
    case 7:
    strcpy(Month,"JUL");
    break;
    case 8:
    strcpy(Month,"AUG");
    break;
    case 9:
    strcpy(Month,"SEP");
    break;
    case 10:
    strcpy(Month,"OCT");
    break;
    case 11:
    strcpy(Month,"NOV");
    break;
    case 12:
    strcpy(Month,"DEC");
    break;
    }
    printf ("Military format =");
    if (day < 10)
    printf ("\t\t0%d-", day);
    if (day >= 10)
    printf ("\t\t%d-", day);
    printf ("%s-", Month);
    printf ("19%d\n", year);




    return;
    }

    void Business (int month, int day, int year)
    {
    char Month[15];
    switch (month)
    {
    case 1:
    strcpy(Month,"January");
    break;
    case 2:
    strcpy(Month,"February");
    break;
    case 3:
    strcpy(Month,"March");
    break;
    case 4:
    strcpy(Month,"April");
    break;
    case 5:
    strcpy(Month,"May");
    break;
    case 6:
    strcpy(Month,"June");
    break;
    case 7:
    strcpy(Month,"July");
    break;
    case 8:
    strcpy(Month,"August");
    break;
    case 9:
    strcpy(Month,"September");
    break;
    case 10:
    strcpy(Month,"October");
    break;
    case 11:
    strcpy(Month,"November");
    break;
    case 12:
    strcpy(Month,"December");
    break;
    }
    printf ("Business format =\t\t%d %s 19%d\n", day, Month, year);


    return;
    }



  2. #2
    Join Date
    Apr 1999
    Posts
    12

    Re: Beginner Request help w/ Assignment

    Let's see...

    *First of all, you're referencing 'GetDatemonth' in your main function. There doesn't appear to be a variable or function with this name; I can only assume you meant to use 'month' instead.

    *The second error is caused because you haven't given a statement for the 'if' portion of the if/else clause in GetDate(). Even if you don't perform any operations, you still need to add a semicolon before the else:

    if {0 < month > 13 && 0 < day > 32 && 0 < year > 100)
    ; // Do nothing
    else
    break;

    By the way, you can't specify Boolean conditions this way. '<' and '>' are binary operators, and you need to have exactly two operands for each. It would be nice to use statements like '0 < month > 13', but this is illegal in c/c++.


  3. #3
    Join Date
    Apr 1999
    Posts
    13

    Re: Beginner Request help w/ Assignment

    Thanks to everyone for your help. I made corrections and understand my errors. It is now running! THANKS MUCH!!!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured