shahpur2004's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
31 (0.04 per day)
Joined:
02-February 12
Profile Views:
713
Last Active:
User is offline Apr 30 2012 08:59 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   shahpur2004 has not set their status

Posts I've Made

  1. In Topic: I have a Date class how can I make two of it's function work prope

    Posted 30 Apr 2012

    I figured out that function, but do you have any suggestion for this function.
    I think my if statements are not coded well that is why it is not working specially for the month of februar and for the leap years.
    [void Date::SetDate(int requestedyear, int month, int day )
    {
         if (requestedyear < 0)
         {
            cout<<"Sorry we do not have data for this year.";
            return;
         }
    
        else
            year = requestedyear;
    
    
    
        if (month > 12 || month < 0 )
        {
            cout<<"Invalid month entry."<<endl;
    
        }
    
            numOfmonth = month;
    
    
    
        if (month ==2)
        {
            if(year%400==0&&year%4==0)
        {
            if (numOfmonth = 2)
            {
                numOfday = 29;
            }
    
        }
    
        else if(year%100)
        {
            if (numOfmonth == 2 && numOfday == 29)
            {
                --numOfday;
            }
    
        }
        else if (day > 28)
            cout << " Invalid day entry for month of February.";
    
        }
        else if (month == 9 || month == 4 || month == 6 || month == 11 )
        {
            if (day > 30)
            cout << " Invalid day entry.";
    
        }
        if ( day > 31 )
        cout<<"Invalid day entry."<<endl;
    
            else
            numOfday = day;
    
    }
    ]
    
  2. In Topic: I have a Date class how can I make two of it's function work prope

    Posted 30 Apr 2012

    View Postr.stiltskin, on 30 April 2012 - 06:35 PM, said:

    View Postshahpur2004, on 30 April 2012 - 09:22 PM, said:

    Adanceoneday function does not have argument I could not pass the argument of the AdvanceDays to the Advanceonedays if you have any suggestions I would be very glade.

    This should be obvious to you if you think about it.

    Suppose you have a button and each time you press the button it rings a bell 1 time. What would you do if you want to ring the bell 3 times?

    It is sample I should press it three times but I think it not the case. Do you mean I should call the function three times.
    [void Date::AdvanceDays(int n)
    {
        Date da;
        da.AdvanceOneDay(); //if I pass n in the Advanceongday function it gives me an error. 
    }
    ]
    
  3. In Topic: I have a Date class how can I make two of it's function work prope

    Posted 30 Apr 2012

    View Postjimblumberg, on 30 April 2012 - 06:29 PM, said:

    Post your code in the post body in code tags.

    :code:

    Quote

    Right now I am testing my code but two functions are not working properly;

    Why are they not working properly? Ask specific questions.

    Jim

    I think my if statements are not coded well that is why it is not working
    [void Date::SetDate(int requestedyear, int month, int day )
    {
         if (requestedyear < 0)
         {
            cout<<"Sorry we do not have data for this year.";
            return;
         }
    
        else
            year = requestedyear;
    
    
    
        if (month > 12 || month < 0 )
        {
            cout<<"Invalid month entry."<<endl;
    
        }
    
            numOfmonth = month;
    
    
    
        if (month ==2)
        {
            if(year%400==0&&year%4==0)
        {
            if (numOfmonth = 2)
            {
                numOfday = 29;
            }
    
        }
    
        else if(year%100)
        {
            if (numOfmonth == 2 && numOfday == 29)
            {
                --numOfday;
            }
    
        }
        else if (day > 28)
            cout << " Invalid day entry for month of February.";
    
        }
        else if (month == 9 || month == 4 || month == 6 || month == 11 )
        {
            if (day > 30)
            cout << " Invalid day entry.";
    
        }
        if ( day > 31 )
        cout<<"Invalid day entry."<<endl;
    
            else
            numOfday = day;
    
    }
    ]
    
    
  4. In Topic: how to make these vectors work properly

    Posted 16 Apr 2012

    View PostDavid W, on 12 April 2012 - 02:23 PM, said:

    Since you know in advance of compile time that all you are 'tracking' is words with length 1 to 10 characters long ...

    you could just use an array of 10 int's initialed to 0

    int word_len[ 11 ] = { 0 } ; // not going to use index 0

    Then all you need is something like this:
    cout << "Enter a word ('END' to end) : " << flush;
    while( cin >> word && word != "END" )
    {
       if( word.size() && word.size() < 11 )
          ++word_len[ word.size() ];
       cout << "Enter a word ('END' to end) : " << flush;
    }
    
    
    

    thank you very much it helped me a lot.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

shahpur2004 has no profile comments yet. Why not say hello?