Hey guys, I just need some opinions about this work. I don't need you to do it for me. I'm just a little confused about getting the correct order in the dates (months and days). I know I got to use the while function. So just please let me know any ideas you might have, thanks.

-------------------------------------------------------------------------------------

it prompts the user to enter two dates (months and days only) and outputs one of the following:

date1 comes before date2

date1 comes after date2

date1 is the same as date2

Make sure your program prevents user from entering nonsense values, such as month 16 and day 38.

The use of a loop may not be warranted in this situation. It seems to me the code is procedurally linear; get user input, perform error checking, test user input, provide output with correct answer.

Using a loop, whether it be while, do/while, or for is usually implemented when several similar operations need to be performed.

One tip: when accepting input from the user, try using a <string> class object.. it will accept all kinds of jibberish and will not crash like trying to accept input strictly into an int, double, float etc.

Once your data has been accepted into the string, perform error checking on that string and then convert string to desired data type.

Edited 7 Years Ago by Clinton Portis: n/a

Hey guys, I just need some opinions about this work. I don't need you to do it for me. I'm just a little confused about getting the correct order in the dates (months and days). I know I got to use the while function. So just please let me know any ideas you might have, thanks.

-------------------------------------------------------------------------------------

it prompts the user to enter two dates (months and days only) and outputs one of the following:

date1 comes before date2

date1 comes after date2

date1 is the same as date2

Make sure your program prevents user from entering nonsense values, such as month 16 and day 38.

When ever you're writing a program always ask yourself these questions. (If you don't already know)
1.) What is the problem statement
2.) What are the input requirements
3.) What are the output requirements

Next write out an algorithm (these are you're best friends when ya learn how to write them). So you need to first determine which date is greater than the other. However going by what I've seen so far a while loop isn't needed. if else if yeah but not while, unless you're asking them to input multiple pieces of info. If that's the case then you would need to put something in the loop that checks which is greater and which less with each iteration and output to the screen what's asked. If you have any other questions pm me. Hope this helped.

This article has been dead for over six months. Start a new discussion instead.