Tuesday, July 14, 2009

I need help with "if" statements in C++ Microsoft Visual Studio 2005!?

ok, so im doing a homework project for my computer science class and we have to use C++ and 'if' statements





i need to make the statement go like this...


i have to have an expiration date and the current date (the expiration date is for a food product)





i have all the integers saved from the dates like this (currentmonth, currentday, currentyear, expirationmonth, expirationday, expirationyear)





then i need to make a bool function called 'thesame' that is true if the dates are the same, and false if they are not





please, will someone help me with this or show me an example of what it might look like, the book doesnt help for this class and its due tomorrow

I need help with "if" statements in C++ Microsoft Visual Studio 2005!?
Its easy....





boolean thesame(int currentmonth,int currentday,


int currentyear,int expirationmonth,


int expirationday,int expirationyear)


{





if ((currentmonth+currentday+


currentyear) ==


(expirationmonth+


expirationday+expirationyear))


{ return true; }





else


{return false;}





}





sorry for all the line ends but yahoo won't display them if i don't add them.
Reply:If you just want to know if they are the same





bool thesame(int currM, currD, currY, expM, expD, expY)


{


if(currM == expM %26amp;%26amp; currD == expD %26amp;%26amp; currY == expY){


return true;


else{


return false;


}


}





You would have to do a little more work if you want to know if it is before or after.


No comments:

Post a Comment