Calculating Age with Zodiac Sign In C#
If you find it hard to Calculating Age with Zodiac Sign In C# of your relative or anyone else close to you. Even its just a simple arithmetic, it still makes you feel dizzy to know someone’s age just by its year. This tutorial will help you on how to calculate age with its corresponding zodiac sign. Now, you don’t have to google what’s your zodiac sign or your friends’ because this method will let you know about it after calculating your age. This is not just useful but its also kinda fun.
Let’s begin:
Open Microsoft Visual Studio and create a new windows form application. after that, do the form just like this.
After setting up the form, go to the solution explorer and hit the “view code” to fire the code editor.
In the code editor, declare and initialize the variables that you’re going to use in public.
//SET AN ARRAY VARIABLE TO STORE THE VALUE OF THE ZODIAC SIGNS ON IT. string[] Zodiac_Sign = new string[12]{"Aries", "Taurus", "Gemini", "Cancer","Leo", "Virgo", "Libra", "Scorpio", "Sagittarius","Capricorn"ca, "Aquarius", "Pisces"}; //SET A VARIABLE TO REPRESENTS YOUR AGE. int age;
After that, go back to the design view, double-click the “calculate” button and do the following code in the method.
//SET THE STRING VARIABLE REPRESENT A FORMATED DATETIMEPICKER TO THE NAME OF THE MONTHS. string months = dtpDateBirth.Value.Date.ToString("MMMM"); //SET THE INTEGR VARIABLE REPRESENT A FORMATED DATETIMEPICKER TO A VALUE OF THE DAY. int days = int.Parse(dtpDateBirth.Value.Date.ToString("dd")); //CALCULATING THE INTERVAL BETWEEN THE DATE OF BIRTH AND THE END OF THE DATE. age = dtpEndDate.Value.Year - dtpDateBirth.Value.Year; //CLEARING THE LISTBOX. listBox1.Items.Clear(); //ADDING THE VALUE OF THE AGE IN THE LISTBOX TAHT YOU HAVE CALCULATED. listBox1.Items.Add("Age : " + age.ToString()).ToString(); switch (months) { case "January": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[9]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[10]); } break; case "February": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[10]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[11]); } break; case "March": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[0]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[11]); } break; case "April": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[0]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[1]); } break; case "May": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[1]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[2]); } break; case "June": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[2]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[3]); } break; case "July": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[3]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[4]); } break; case "August": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[4]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[5]); } break; case "September": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[5]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[6]); } break; case "October": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[6]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[7]); } break; case "november": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[7]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[8]); } break; case "December": if (days >= 1 && days <= 19) { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[8]); } else { //ADDING A ZODIAC SIGN IN THE LIST BOXS. listBox1.Items.Add("Zodiac Sign :" + Zodiac_Sign[9]); } break; };
Output:
For all students who need a programmer for your thesis system or anyone who needs a sourcecode in any programming languages. You can contact me @ :
Email – [email protected]
Mobile No. – 09305235027 – tnt
I am no longer positive the place you’re getting your information, but
good topic. I needs to spend a while learning much more or understanding more.
Thank you for fantastic information I used to be in search
of this info for my mission.