Zodiac Sign Identifier using C#
Submitted by donbermoy on Sunday, July 6, 2014 - 19:21.
In this tutorial, I will teach you how to create a program that identifies your zodiac sign with regards to your date of birth in Visual Studio 2010 using C# language. Its not just an ordinary if and else statement, or switch statement but it undergoes date manipulation.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application in C# for this tutorial by following the following steps in Microsoft Visual Studio 2010: Go to File, click New Project, and choose Windows Application.
2. Next, add dateTimepicker named DTPDATEBIRTH for inputting of your date of birth, a button named Button1 for processing your zodiac sign, and a ListBox named ListBox1 for displaying your zodiac. You must design your interface like this:
3. In your code view, declare a global array variable to store the value of the zodiac signs on it.
4. In your Button1_Click, put this code below.
Declare a string variable to format the datetimepicker to the name of the months.
Declare an integer variable represent a formatted the datetimepicker to a value of the day.
Conditioning the months and the days inorder to put the specific zodiac zign.
Lastly, clear the Listbox.
Output:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- string[] zodiac = new string[] {"Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"};
- string months = Strings.Format(DTPDATEBIRTH.Value, "MMMM");
- int days = int.Parse(Strings.Format(DTPDATEBIRTH.Value, "dd"));
- switch (months)
- {
- case "January":
- if (days >= 1 & days <= 19)
- {
- //ADDING A ZODIAC SIGN IN THE LIST BOXS.
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[9]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[10]);
- }
- break;
- case "February":
- if (days >= 1 & days <= 18)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[10]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[11]);
- }
- break;
- case "March":
- if (days >= 21)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[0]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[11]);
- }
- break;
- case "April":
- if (days >= 1 & days <= 19)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[0]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[1]);
- }
- break;
- case "May":
- if (days >= 1 & days <= 20)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[1]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[2]);
- }
- break;
- case "June":
- if (days >= 1 & days <= 21)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[2]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[3]);
- }
- break;
- case "July":
- if (days >= 1 & days <= 22)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[3]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[4]);
- }
- break;
- case "August":
- if (days >= 1 & days <= 22)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[4]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[5]);
- }
- break;
- case "September":
- if (days >= 1 & days <= 22)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[5]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[6]);
- }
- break;
- case "October":
- if (days >= 1 & days <= 22)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[6]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[7]);
- }
- break;
- case "November":
- if (days >= 1 & days <= 21)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[7]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[8]);
- }
- break;
- case "December":
- if (days >= 1 & days <= 21)
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[8]);
- }
- else
- {
- ListBox1.Items.Add("Zodiac Sign :" + zodiac[9]);
- }
- break;
- }
- }
- ListBox1.Items.Clear();
Add new comment
- 3438 views