CMSC222: Project 4, Birthday
Section 30118: Due Sunday, March 30, 2025
Create a C# program that will use a date time pickercontrol to let the user select his birthday.
The dateTimePicker can be used to extract the month, day and year as shown below:
private void DateTimePicker1_ValueChanged(object sender, EventArgs e)
{
DateTime d = dateTimePicker1.Value;
this.Text = ""+d.Date.Month;
}
After a date is selected, display the following information:
This assignment MUST be done using arrays wherever appropriate.
- The day of the week he was born on.
- His Chinese year (dragon, boar, etc.) and an appropriate picture. (This is an array problem using the year % 12)
If the year mod 12 is
Year %12 |
Animal |
0 |
monkey |
1 |
rooster |
2 |
dog |
3 |
pig |
4 |
rat |
5 |
ox |
6 |
tiger |
7 |
rabbit |
8 |
dragon |
9 |
snake |
10 |
horse |
11 |
sheep |
- The season: You may use March 20th for the first day of Spring. Use June 20th for the first day of summer, September 22 for the first day of fall, and December 21 as the first day of winter. This will be easier if you combine the month and day into one number using month*100+day. Use an array to store the first date for each season, then loop to see where a date falls.
- His zodiac sign (Aquarius, etc. ) and a picture. This is also an array problem, but more complicated because you must search for the date to be within a range. This will be easier if you combine the month and day into one number using month*100+day. Then Aquarius is anywhere between 121 and 219.
int[] bounds = { 0, 121, 220, 321, 421, 522, 622, 723, 822, 924, 1024, 1123, 1223, 1300 };
Please see video on furniture-assembly and seasons for an explanation of this algorithm.
Aquarius - January 21 - February 19
Pisces - February 20- March 20
Aries - March 21 - April 20
Taurus - April 21 - May 21
Gemini- May 22 - June 21
Cancer - June 22 - July 22
Leo - July 23 -August 21
Virgo - August 22 - September 23
Libra - September 24 - October 23
Scorpio - October 24 - November 22
Sagittarius - November 23 - December 22
Capricorn - December 23 - January 20
Use Google to find information about the Chinese years and the zodiac signs and to find pictures or use these pictures
Aside from using arrays this project is important because it is complex enough that you must write it one step at a time.
You can start with any step you understand, but this is an example.
- Create an array of the Chinese zodaic signs.
- Get just the year from the date picker (this.dateTimePicker1.Value.Year) and print the sign.
- Add a picture of the animal.
- Add each additional step in the same way.
This is a fun and interesting project that combines some of the skills you have learned. It is not important whether you believe in Astrology or not.
When you finish, save and close.
Zip the whole project folder to create Lastname_Firstname_birthday.zip.
Upload the project in Blackboard.
Images
If you put the images in the Birthdays/bin/debug/images/ directory, this will display the picture:
String localDirectory = System.IO.Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);
this.Text = localDirectory;
picAnimals.Image = Image.FromFile(localDirectory + "/images/rat.png"); //use the year % 12 to find actual picture required.
The following are requirements:
If any of these requirements are not met, the score will be 0.
If the requirements are met, the grade is as follows:
Possible points=50
Please see https://www.zebra0.com/MC/CMSC222/resource/CMSC222zip.php for instructions on zipping the entire folder.
If you do not receive a perfect score you may resubmit it as long as it is resubmitted within 3 days.
Assignment IndexThis web site, and all pages therein, are the sole property and responsibility of Zebra0.com.
It is not endorsed, sponsored, or provided by or on behalf of Montgomery College.