The program handin33 will only submit files in the cs33/lab/07 directory. (You should run update33 first to set up the directory and create any necessary files.)
Remember: You are encouraged to work with a partner.
Each program must follow these following guidelines:
float raiseRealToPower(float base, int exponent);
This function will raise base the power exponent. The base can be any floating point value (negative, positive, zero) and the exponent can be any integer value (negative, positive, zero).
After you have written this function, test that the function is working by displaying a table of the powers of 0.5 between -15 and +5. Your table should be similar, but necessarily exactly the same as this:
-15 32768.00000 -14 16384.00000 -13 8192.00000 -12 4096.00000 -11 2048.00000 -10 1024.00000 -9 512.00000 -8 256.00000 -7 128.00000 -6 64.00000 -5 32.00000 -4 16.00000 -3 8.00000 -2 4.00000 -1 2.00000 0 1.00000 1 0.50000 2 0.25000 3 0.12500 4 0.06250 5 0.03125
You will begin by prompting the user for a year between 1980 and 2030. If the year is not between 1980 and 2030, remind the user that the year must be between those two years and ask again. After the user has entered a valid year, you will show a table similar to the one shown in the sample output located at the end of the question. Though the exact number of spaces doesn't have to match, it should be well formatted.
The following is a list of all nationally observed U.S. federal holidays. There are a number of caveats to this list, so be sure to read all of the instructions in this question carefully:
Name | Date |
New Year's Day | January 1 |
Birthday of Martin Luther King, Jr. | 3rd Monday in January |
Washington's Birthday | 3rd Monday in Feburary |
Memorial Day | Last Monday in May |
Independence Day | July 4 |
Labor Day | 1st Monday in September |
Columbus Day | 2nd Monday in October |
Veteran's Day | November 11 |
Thanksgiving Day | 4th Thursday in November |
Christmas Day | December 25 |
Federal employees get one day off from work for each of these federal holidays, even if the day falls on a weekend. Holidays which fall on Saturday are observed the previous day (Friday) and holidays which fall on Sunday are observed the following day (Monday). Therefore, the observed day of a holiday is always a weekday (Monday-Friday).
Important note: On some years (such as 2005), New Year's Day falls on a Saturday. When this happens, the holiday is observed on Friday, December 31, 2004. That means that a) New Year's Day is not observed in 2005, and b) there are two New Year's Day observations in 2004 (Thursday, January 1, 2004 and Friday, December 31, 2004). You should handle this special case.
You can view the "answers" on the website of the U.S. Office of Personnel Management. (In 2010, they mistakenly do not list the observance of 2011's New Year on 12/31/2010 as they should.)
Your program should have at least the following four functions:
This function should return -1 whenever:
Here are a few runs of the program to give you an idea what I'm looking for:
lab[~]$ ./usholidays Enter a year between 1980 and 2030: 2008 New Year's Day 01/01/2008 Birthday of Martin Luther King, Jr. 01/21/2008 Washington's Birthday 02/18/2008 Memorial Day 05/26/2008 Independence Day 07/04/2008 Labor Day 09/01/2008 Columbus Day 10/13/2008 Veteran's Day 11/11/2008 Thanksgiving Day 11/27/2008 Christmas Day 12/25/2008 lab[~]$ ./usholidays Enter a year between 1980 and 2030: 1904 The year must be between 1980 and 2030. Enter a year between 1980 and 2030: 1945 The year must be between 1980 and 2030. Enter a year between 1980 and 2030: 2004 New Year's Day 01/01/2004 Birthday of Martin Luther King, Jr. 01/19/2004 Washington's Birthday 02/16/2004 Memorial Day 05/31/2004 Independence Day 07/05/2004 Labor Day 09/06/2004 Columbus Day 10/11/2004 Veteran's Day 11/11/2004 Thanksgiving 11/25/2004 Christmas Day 12/24/2004 New Year's Day 12/31/2004 lab[~]$ ./usholidays Enter a year between 1980 and 2030: 2005 Birthday of Martin Luther King, Jr. 01/17/2005 Washington's Birthday 02/21/2005 Memorial Day 05/30/2005 Independence Day 07/04/2005 Labor Day 09/05/2005 Columbus Day 10/10/2005 Veteran's Day 11/11/2005 Thanksgiving 11/24/2005 Christmas Day 12/26/2005
Extend the usholidays.c program to include Election Day which you should add to the calendar only during years in which there is a presidential election (in years divisible by 4). Election Day is always the first Tuesday after the first Monday in November.