Explore BrainMass

ranges and functions

This content was STOLEN from BrainMass.com - View the original, and get the solution, here!

You have functions that you wish to call for various individual year values, as well as ranges of years, and you are deciding on whether to use an if statement or a switch statement. The ranges and functions are:

o 1900 to 1969 - functionA()

o 1969 to 2000 - functionB()

o 2001 - functionC()

o 2002, 2003 - functionD()

o 2004 and beyond - functionE()

Do you think it would be better to set this up as an if statement, a switch statement, or a combination? Write the code if it helps to explain your answer.

© BrainMass Inc. brainmass.com September 25, 2018, 3:17 am ad1c9bdddf - https://brainmass.com/computer-science/programming-languages/ranges-functions-100333

Solution Preview

Since for many year values you need to execute functionA() and functionB(), it would be recommended to setup the code using if statements otherwise one has to write too many case statements for each year in the range to execute the corresponding function. The following piece of code would ...

Solution Summary

This job applies ranges and functions.