About zodiac sign in java

About zodiac sign in java

View Answers

July 16, 2009 at 11:33 AM

Hi Friend,

Try the following code:

import java.util.*;

public class ZodiacSign {
public static void main(String[] args) {
String sign="";
String element="";
String chineseSign="";
int month, day,year;

Scanner c = new Scanner (System.in);
System.out.println("Enter day(1-31): ");
day = c.nextInt();
System.out.println("Enter month(1-12): ");
month = c.nextInt();
System.out.println("Enter year: ");
year = c.nextInt();

if((month == 1) && (day <= 20) || (month == 12) && (day >= 22)) {
sign = "Capricorn";
} else if((month == 1) || (month == 2) && (day <= 19)) {
sign = "Aquarius";
} else if((month == 2) || (month == 3) && (day <= 20)) {
sign = "Pisces";
} else if((month == 3) || (month == 4) && (day <= 19)) {
sign = "Aries";
} else if((month == 4) || (month == 5) && (day <= 21)) {
sign = "Taurus";
} else if((month == 5) || (month == 6) && (day <= 21)) {
sign = "Gemini";
} else if((month == 6) || (month == 7) && (day <= 23)) {
sign = "Cancer";
} else if((month == 7) || (month == 8) && (day <= 23)) {
sign = "Leo";
} else if((month == 8) || (month == 9) && (day <= 23)) {
sign = "Virgo";
} else if((month == 9) || (month == 10) && (day <= 23)) {
sign = "Libra";
} else if((month == 10) || (month == 11) && (day <= 22)) {
sign = "Scorpio";
} else if(month == 12) {
sign = "Sagittarius";
}
if((sign.equals("Aries"))||(sign.equals("Leo"))||(sign.equals("Sagittarius"))){
element="Fire";
}
else if((sign.equals("Taurus"))||(sign.equals("Virgo"))||(sign.equals("Capricorn"))){
element="Earth";
}
else if((sign.equals("Gemini"))||(sign.equals("Libra"))||(sign.equals("Aquarius"))){
element="Air";
}
else if((sign.equals("Cancer"))||(sign.equals("Scorpio"))||(sign.equals("Pisces"))){
element="Water";
}

int x = (1997 - year) % 12;
if ((x == 1) || (x == -11)){
chineseSign="Rat";
}
else{
if (x == 0){
chineseSign="Ox";
}
else{
if ((x == 11) || (x == -1)){
chineseSign="Tiger";
}
else{
if ((x == 10) || (x == -2)){
chineseSign="Rabbit";
}
else{
if ((x == 9) || (x == -3)){
chineseSign="Dragon";
}
else{
if ((x == 8) || (x == -4)){
chineseSign="Snake";
}
else{
if ((x == 7) || (x == -5)){
chineseSign="Horse";
}
else{
if ((x == 6) || (x == -6)){
chineseSign="Sheep";
}
else{
if ((x == 5) || (x == -7)){
chineseSign="Monkey";
}
else{
if ((x == 4) || (x == -8)){
chineseSign="Chicken";
}
else{
if ((x == 3) || (x == -9)){
chineseSign="Dog";
}
else{
if ((x == 2) || (x == -10)){
chineseSign="Pig";
}
}
}
}
}
}
}
}
}
}
}
}

System.out.println("Your Zodiac sign is "+sign+".");
System.out.println("Chinese Zodiac is: "+chineseSign+".");
System.out.println("Element is "+element+".");
}
}
Thanks









Related Tutorials/Questions & Answers:
About zodiac sign in java - Java Beginners
About zodiac sign in java  Hello again.. I need help.. Our assgnment in programming is like this. Input your Bday and the output are your zodiac sign,, your chinese zodiac sign (year, ex: rat, pig, dragon etc..) and the element
How to put multiple predictions for one zodiac sign, Java Horoscope!
How to put multiple predictions for one zodiac sign, Java Horoscope!  ... would choose: Your zodiac sign is Virgo. You're going to be lucky tomorrow OR Your zodiac sign is Virgo. Next Monday will be very romantic? Thank you!  
Advertisements
ModuleNotFoundError: No module named 'zodiac-sign'
ModuleNotFoundError: No module named 'zodiac-sign'  Hi, My Python... 'zodiac-sign' How to remove the ModuleNotFoundError: No module named 'zodiac-sign' error? Thanks   Hi, In your python environment
Find Zodiac Sign
Find Zodiac Signs using Java Programming In this section, you will learn how to find the zodiac sign and chinese sign. For this, We have differentiated all... is differentiated according to the zodiac sign. The given program prompt the user to enter his
ModuleNotFoundError: No module named 'zodiac'
ModuleNotFoundError: No module named 'zodiac'  Hi, My Python... 'zodiac' How to remove the ModuleNotFoundError: No module named 'zodiac'... to install padas library. You can install zodiac python with following command
About Java
About Java  Hi, Can anyone tell me the About Java programming language? How a c programmer can learn Java development techniques? Thanks   Hi, Read about java at http://www.roseindia.net/java. Thanks
about java
about java  how to get the value from the user like c, c++ program pls explain with example for me
About java
About java   how we insert our database data into the jTable in java or how we show database content into the JTable in java   Hi Friend,ADS_TO_REPLACE_1 Try the following code: import
about J2EE. - Java Beginners
about J2EE.  I know only core Java ... what chapter I will be learn to know about J2EE
about jboss - Java Beginners
about jboss  can you please explain about jboss...how to deploy,where the temp and lock is there...total information about jboss to use in java message services(JMS
Maven dependency for cn.bestwu - api-sign version 1.0.0 is released. Learn to use api-sign version 1.0.0 in Maven based Java projects
( cn.bestwu - api-sign version 1.0.0 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.0.0 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.0.0 java
Maven dependency for cn.bestwu - api-sign version 1.0.1 is released. Learn to use api-sign version 1.0.1 in Maven based Java projects
( cn.bestwu - api-sign version 1.0.1 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.0.1 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.0.1 java
Maven dependency for cn.bestwu - api-sign version 1.1 is released. Learn to use api-sign version 1.1 in Maven based Java projects
- api-sign version 1.1 ) in their Java project if it is based on Maven and Gradle... to use  cn.bestwu - api-sign version 1.1 in Java projects. Follow the step by step... that downloads and includes  cn.bestwu - api-sign version 1.1 java library in your
Maven dependency for cn.bestwu - api-sign version 1.1.1 is released. Learn to use api-sign version 1.1.1 in Maven based Java projects
( cn.bestwu - api-sign version 1.1.1 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.1.1 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.1.1 java
Maven dependency for cn.bestwu - api-sign version 1.1.2 is released. Learn to use api-sign version 1.1.2 in Maven based Java projects
( cn.bestwu - api-sign version 1.1.2 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.1.2 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.1.2 java
Maven dependency for cn.bestwu - api-sign version 1.1.3 is released. Learn to use api-sign version 1.1.3 in Maven based Java projects
( cn.bestwu - api-sign version 1.1.3 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.1.3 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.1.3 java
Maven dependency for cn.bestwu - api-sign version 1.1.4 is released. Learn to use api-sign version 1.1.4 in Maven based Java projects
( cn.bestwu - api-sign version 1.1.4 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.1.4 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.1.4 java
Maven dependency for cn.bestwu - api-sign version 1.1.5 is released. Learn to use api-sign version 1.1.5 in Maven based Java projects
( cn.bestwu - api-sign version 1.1.5 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.1.5 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.1.5 java
Maven dependency for cn.bestwu - api-sign version 1.2.0 is released. Learn to use api-sign version 1.2.0 in Maven based Java projects
( cn.bestwu - api-sign version 1.2.0 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.2.0 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.2.0 java
Maven dependency for cn.bestwu - api-sign version 1.2.1 is released. Learn to use api-sign version 1.2.1 in Maven based Java projects
( cn.bestwu - api-sign version 1.2.1 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.2.1 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.2.1 java
Maven dependency for cn.bestwu - api-sign version 1.2.2 is released. Learn to use api-sign version 1.2.2 in Maven based Java projects
( cn.bestwu - api-sign version 1.2.2 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.2.2 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.2.2 java
Maven dependency for cn.bestwu - api-sign version 1.2.3 is released. Learn to use api-sign version 1.2.3 in Maven based Java projects
( cn.bestwu - api-sign version 1.2.3 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.2.3 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.2.3 java
Maven dependency for cn.bestwu - api-sign version 1.2.4 is released. Learn to use api-sign version 1.2.4 in Maven based Java projects
( cn.bestwu - api-sign version 1.2.4 ) in their Java project if it is based on Maven... to use  cn.bestwu - api-sign version 1.2.4 in Java projects. Follow the step... code that downloads and includes  cn.bestwu - api-sign version 1.2.4 java
Maven dependency for com.alexvasilkov - android_sign version 0.2 is released. Learn to use android_sign version 0.2 in Maven based Java projects
use this version ( com.alexvasilkov - android_sign version 0.2 ) in their Java... - android_sign version 0.2 in Java projects. Follow the step by step tutorial..._sign version 0.2 java library in your project. ADS_TO_REPLACE_2 Now you can save
Maven dependency for com.alexvasilkov - android_sign version 0.1 is released. Learn to use android_sign version 0.1 in Maven based Java projects
use this version ( com.alexvasilkov - android_sign version 0.1 ) in their Java... - android_sign version 0.1 in Java projects. Follow the step by step tutorial..._sign version 0.1 java library in your project. ADS_TO_REPLACE_2 Now you can save
about J2EE. - Java Beginners
about J2EE.  I know only core Java ... what chapter I will be learn to know about J2EE.  Hi Friend, Please visit the following link: http://www.roseindia.net/ Thanks
SMART VEHICLE ROAD SIGN IDENTIFICATION
SMART VEHICLE ROAD SIGN IDENTIFICATION  JAVA code for "SMART VEHICLE ROAD SIGN IDENTIFICATION
About basics - Java Beginners
About basics  Why we are typing java program in text editor? Why we are running the java program in command prompt
Ask about java
Ask about java  Create a java program for add and remove the details of a person, which is not using by database, a simply java program. If possible, please wil it in switch case
Maven dependency for com.alexvasilkov - android-sign-release version 0.8.1 is released. Learn to use android-sign-release version 0.8.1 in Maven based Java projects
- android-sign-release version 0.8.1 java library in your project. ADS_TO_REPLACE_2...-sign-release released The developers of   com.alexvasilkov - android-sign-release project have released the latest version of this library on 04 Nov
Maven dependency for com.alexvasilkov - android-sign-release version 0.8 is released. Learn to use android-sign-release version 0.8 in Maven based Java projects
? Steps to use  com.alexvasilkov - android-sign-release version 0.8 in Java...-sign-release released The developers of   com.alexvasilkov - android-sign-release project have released the latest version of this library on 29 Oct
Maven dependency for com.alexvasilkov - android-sign-release version 0.7 is released. Learn to use android-sign-release version 0.7 in Maven based Java projects
? Steps to use  com.alexvasilkov - android-sign-release version 0.7 in Java...-sign-release released The developers of   com.alexvasilkov - android-sign-release project have released the latest version of this library on 22 Oct
Maven dependency for com.alexvasilkov - android-sign-release version 0.5 is released. Learn to use android-sign-release version 0.5 in Maven based Java projects
? Steps to use  com.alexvasilkov - android-sign-release version 0.5 in Java...-sign-release released The developers of   com.alexvasilkov - android-sign-release project have released the latest version of this library on 21 Oct
Maven dependency for com.alexvasilkov - android-sign-release version 0.4 is released. Learn to use android-sign-release version 0.4 in Maven based Java projects
? Steps to use  com.alexvasilkov - android-sign-release version 0.4 in Java...-sign-release released The developers of   com.alexvasilkov - android-sign-release project have released the latest version of this library on 27 Sep
Maven dependency for com.alexvasilkov - android-sign-release version 0.3.7 is released. Learn to use android-sign-release version 0.3.7 in Maven based Java projects
- android-sign-release version 0.3.7 java library in your project. ADS_TO_REPLACE_2...-sign-release released The developers of   com.alexvasilkov - android-sign-release project have released the latest version of this library on 29 Jul
Maven dependency for com.alexvasilkov - android-sign-release version 0.3.6 is released. Learn to use android-sign-release version 0.3.6 in Maven based Java projects
- android-sign-release version 0.3.6 java library in your project. ADS_TO_REPLACE_2...-sign-release released The developers of   com.alexvasilkov - android-sign-release project have released the latest version of this library on 03 Jun
about swings - Java Beginners
about swings   Dear sir,Good evening, i am doing mca sir,i am doing the project in swings,so plz provide the material about swings sir...: http://www.roseindia.net/java/example/java/swing/ Hope
about enum - Java Beginners
about enum  hi all, please tell me about "enum" and explain with example. And its use in OOP. Thanks
about c and java
about c and java   i need java and c language interview and objective questions with answers for the fresher.please provide to me   Please visit the following links: http://www.roseindia.net/java/ http
about java - Java Beginners
about java  hello, being a begineer in Java i would like know that as we read the value entered by user through cin>> in c++ how we did it with java.  Hi Friend, There are lot of ways to input data.You can use
Questions about Java's String pool
Questions about Java's String pool  Questions about Java's String pool
about package - Java Beginners
about package  as i am programming a question based on creating own... in the root directory.In my system java is installed in c:\ibm\java142\bin how can i run...://www.roseindia.net/java/master-java/java-package.shtml Hope
about interface - Java Beginners
about interface  can anyone explain to me the implementation of the given line Set si=new HashSet(); Problem is that Set is an interface...://www.roseindia.net/java
about array in java
about array in java  speed of a vehicle is measured using the total time and the distance by using the equation given bellow speed(km/hour)=distance... Vehicle 02 = 5 hours Write a JAVA class to represent the Vehicle. The program should
about JAVA - Java Beginners
about JAVA  i have to create a program that will sort the given numbers using bubble sort. the user will enter the number of inputs as well...; } } } } } ------------------------------------------- Read for more information, http://www.roseindia.net/java
about coding - Java Beginners
about coding  hello sir, I want to create session expair, when user is not enter anything in login page session wil expair after 10 min.if user enter its go to success page.plz send me full code about this. thanks
About inheritanance in JAVA
About inheritanance in JAVA  What is need foe the Inheritance in though we can access any method of any class declared publicly in simple class calling
About Java - Java Interview Questions
About Java  what is edition of java? versions of weblogic? what r the webserver applications used in your application
about instance of java
about instance of java  1> what is an instance 2> what is an object 3>what is difference between above two   Hi Friend, An Instance creates the reference of an object. An object is a run time entity
about JVM - Java Beginners
about JVM  Hello Rose india.net team I want to ask that why JVM is platform dependent is it automatically installs whenever we install jdk or is it automatically installed whenever we install operating system on our machine

Ads