Ask your own question, for FREE!
Computer Science 21 Online
OpenStudy (anonymous):

write a function that takes a name as parameter and return the number of day in that months

OpenStudy (anonymous):

name are you asking to accept month's name ?

OpenStudy (anonymous):

yes

OpenStudy (anonymous):

int function ( string temp ) { switch ( temp ) { case "january" : return 1; break; case "February" : return 2; break; case "march" : return 3; break; case "April" : return 4; break; . . . . default : return 0; }

OpenStudy (anonymous):

He said returns the number of days in that month, so for January for example it will be : case "january" : return 31; Good luck.

OpenStudy (anonymous):

Though you'll need some extra logic for February (to account for leap year) - Step 1 - If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5. - Step 2 - If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4. - Step 3 - If the year is evenly divisible by 400, go to step 4. Otherwise, go to step 5. - Step 4 - The year is a leap year (it has 366 days). - Step 5 - The year is not a leap year (it has 365 days).

OpenStudy (anonymous):

cases January, March, May, July, August, October, December all have 31 days, so they can be nested. case February has either 28 or 29. the default would be 30.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!