Write a C++ function named dateIsBefore that takes as parameters two month/day combinations and that returns whether or not the first date comes before the second date (true if the first month/day comes before the second month/day, false if it does not). The method will take four integers as parameters that represent the two month/day combinations. The first integer in each pair represents the month and will be a value between 1 and 12 (1 for January, 2 for February, etc, up to 12 for December). The second integer in each pair represents the day of the month (a value between 1 and 31). One date is considered to come before another if it comes earlier in the year. Below are sample calls of your function. Call Return Explanation dateIsBefore(6, 3, 9, 20) true June 3 comes before Sep 20 dateIsBefore(10, 1, 2, 25) false Oct 1 does not come before Feb 25 dateIsBefore(8, 15, 8, 15) false Aug 15 does not come before Aug 15 dateIsBefore(8, 15, 8, 16) true Aug 15 comes before Aug 16
Write a C++ function named dateIsBefore that takes as parameters two month/day combinations and that returns whether or not the first date comes before the second date (true if the first month/day comes before the second month/day, false if it does not). The method will take four integers as parameters that represent the two month/day combinations.
The first integer in each pair represents the month and will be a value between 1 and 12 (1 for January, 2 for February, etc, up to 12 for December). The second integer in each pair represents the day of the month (a value between 1 and 31). One date is considered to come before another if it comes earlier in the year.
Below are sample calls of your function.
Call | Return | Explanation |
---|---|---|
dateIsBefore(6, 3, 9, 20) | true | June 3 comes before Sep 20 |
dateIsBefore(10, 1, 2, 25) | false | Oct 1 does not come before Feb 25 |
dateIsBefore(8, 15, 8, 15) | false | Aug 15 does not come before Aug 15 |
dateIsBefore(8, 15, 8, 16) | true | Aug 15 comes before Aug 16 |
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images