Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,148,685 members, 7,801,974 topics. Date: Friday, 19 April 2024 at 07:17 AM

A Program To Tell Ur Zodiac Sign - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / A Program To Tell Ur Zodiac Sign (12192 Views)

Java Program To Solve Quadratic Equation-dealwap / Program To Sign The Greek Finance Minister's Signature - Contest For ₦20,000 / [problem] Write A Program In C++ That Finds The Hcf Of 2 Numbers Without Using A Recursive Function (2) (3) (4)

(1) (Reply) (Go Down)

A Program To Tell Ur Zodiac Sign by xteve(m): 4:49pm On Dec 27, 2012
Hi programmers in the house Hope u all had a wonderful Christmas Celebration?

I have been thinking on a proper algorithm/way to write a simple program that will prompt a user to enter his personal details. Then the program should be able to tell the person's zodiac sign using Java, C++ or even python.
Below are the zodiac signs and their dates

Aries March 21-April 20
Taurus April 21 - May 21
Gemini May 22 - June 21
Cancer June 22 - July 22
Leo July 23 - August 22
Virgo August 23 - September 22
Libra September 23 - October 22
Scorpio October 23 - November 21
Sagittarius November 22 - December 21
Capricorn December 22 - January 19
Aquarius January 20 - February 18
Pisces February 19 - March 20


Any opinion will be welcm
Re: A Program To Tell Ur Zodiac Sign by lordZOUGA(m): 6:41pm On Dec 27, 2012
xteve: Hi programmers in the house Hope u all had a wonderful Christmas Celebration?

I have been thinking on a proper algorithm/way to write a simple program that will prompt a user to enter his personal details. Then the program should be able to tell the person's zodiac sign using Java, C++ or even python.
Below are the zodiac signs and their dates

Aries March 21-April 20
Taurus April 21 - May 21
Gemini May 22 - June 21
Cancer June 22 - July 22
Leo July 23 - August 22
Virgo August 23 - September 22
Libra September 23 - October 22
Scorpio October 23 - November 21
Sagittarius November 22 - December 21
Capricorn December 22 - January 19
Aquarius January 20 - February 18
Pisces February 19 - March 20


Any opinion will be welcm
this looks like an exercise in a programming textbook..
Re: A Program To Tell Ur Zodiac Sign by xteve(m): 7:03pm On Dec 27, 2012
lordZOUGA:
this looks like an exercise in a programming textbook..

Nice opinion
Re: A Program To Tell Ur Zodiac Sign by Javanian: 8:37pm On Dec 27, 2012


//The Brute-Force method grin
public class dates
{
public static int getNumDate(String month, int day)
{
int numDate = 0;

if(month == "january"wink
{ numDate = 0 + day; }
else if(month == "febuary"wink
{ numDate = 31 + day; }
else if(month == "march"wink
{ numDate = 59 + day; }
else if(month == "april"wink
{ numDate = 90 + day; }
else if(month == "may"wink
{ numDate = 120 + day; }
else if(month == "june"wink
{ numDate = 151 + day; }
else if(month == "july " )
{ numDate = 181 + day; }
else if(month == "august"wink
{ numDate = 212 + day; }
else if(month == "setember"wink
{ numDate = 243 + day; }
else if(month == "october"wink
{ numDate = 273 + day; }
else if(month == "november"wink
{ numDate = 304 + day; }
else if(month == "december"wink
{ numDate = 334 + day; }
return numDate;
}
public static String getZodiac(int date)
{
String zodiac = null;
if(date >=80 && date<=110)
{ zodiac = "aries"; }
else if(date >=111 && date<=141)
{ zodiac = "taurus"; }
if(date >=142 && date<=172)
{ zodiac = "gemini"; }
if(date >=173 && date<=203)
{ zodiac = "cancer"; }
if(date >=204 && date<=234)
{ zodiac = "leo"; }
if(date >=235 && date<=265)
{ zodiac = "virgo"; }
if(date >=266 && date<=295)
{ zodiac = "libra"; }
if(date >=296 && date<=325)
{ zodiac = "scorpio"; }
if(date >=326 && date<=355)
{ zodiac = "sagittarius"; }
if(date >=356 || date<=19)
{ zodiac = "capricorn"; }
if(date >=20 && date<=49)
{ zodiac = "aquarius"; }
if(date >=50 && date<=79)
{ zodiac = "pisces"; }
return zodiac;
}
public static void main(String[] args)
{
int res1 = getNumDate("febuary", 20);
System.out.println(getZodiac(res1));
}

}


Re: A Program To Tell Ur Zodiac Sign by xteve(m): 9:25pm On Dec 27, 2012
Javanian u're awesome. I knew I could count on u and other programmers in the house.
Happy New Year i̶̲̥̅̊n̶̲̥̅̊ adv
Re: A Program To Tell Ur Zodiac Sign by Nobody: 12:11am On Dec 28, 2012
Re: A Program To Tell Ur Zodiac Sign by segsalerty(m): 11:19pm On Dec 28, 2012
Javanian, i dey feel u........ ********winks smiley wink
Re: A Program To Tell Ur Zodiac Sign by Chimanet(m): 11:54pm On Dec 28, 2012
@javanian well done, bt do u knw abt d calender api? I think it will also b possible with it
Re: A Program To Tell Ur Zodiac Sign by Javanian: 1:17am On Dec 29, 2012
^^^

i also thought of that, but i am not to familiar with it, so i found a way round cheesy
Re: A Program To Tell Ur Zodiac Sign by xteve(m): 5:59pm On Jan 02, 2013
Thanks guys
Re: A Program To Tell Ur Zodiac Sign by lordZOUGA(m): 6:27pm On Jan 02, 2013
Chimanet: @javanian well done, bt do u knw abt d calender api? I think it will also b possible with it
how?
Re: A Program To Tell Ur Zodiac Sign by Javanian: 6:36pm On Jan 02, 2013
[url=docs.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html]Java Calendar API[/url]
Re: A Program To Tell Ur Zodiac Sign by lordZOUGA(m): 8:10pm On Jan 02, 2013
I saw...
I still don't get..
Re: A Program To Tell Ur Zodiac Sign by Javanian: 8:30pm On Jan 02, 2013
Please what exactly don't you get? The API or how the API can solve the problem at hand?
Re: A Program To Tell Ur Zodiac Sign by lordZOUGA(m): 9:01pm On Jan 02, 2013
Javanian: Please what exactly don't you get? The API or how the API can solve the problem at hand?
how the calendar api efficiently solves this problem
Re: A Program To Tell Ur Zodiac Sign by Javanian: 9:17pm On Jan 02, 2013
i can't say for sure what he had in mind, but the API has a compareTo method that returns 0 if the dates are equal, >0 if the date in the parameter is after the the initial date and <0 if its before the initial date.

Chimanet: @javanian well done, bt do u knw abt d calender api? I think it will also b possible with it


How ? grin

(1) (Reply)

ALX Virtual Assistant Program / Should A Beginner Learn 2 Programming Languages At Once? / Data Scientists In Nigeria, Lets Talk

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 25
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.