Home Answers Viewqa Java-Beginners About zodiac sign in java

 
 


Hazel
About zodiac sign in java
1 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners

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 Pages:
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
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
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!  
SMART VEHICLE ROAD SIGN IDENTIFICATION
SMART VEHICLE ROAD SIGN IDENTIFICATION  JAVA code for "SMART VEHICLE ROAD SIGN IDENTIFICATION
Login And Sign up
Login And Sign up  how do you create a login and sign up that will automaticly add users and passwords after activation link from auto confirmation email is opened
using $ sign in PHP
using $ sign in PHP  Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example
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 we insert our database data into the jTable in java or how we show database content into the JTable in java   Hi Friend, Try the following code: import java.io.*; import
about J2EE. - Java Beginners
about J2EE.  I know only core Java ... what chapter I will be learn to know about J2EE
about java1
about java1  Sir, i want to know how we develop 3d button ,lable,textfield etc. in java . sir plz give one program as well Thank you
ABOUT Jtable
ABOUT Jtable  My Project is Exsice Management in java swing Desktop Application. I M Use Netbeans & Mysql . How can retrive Data in Jtable from Mysql Database in Net Beans
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
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
About Constructor
About Constructor  How many objects are create when this code will execute... String string = new String("Java is best Lang."); tell me the number of object of string which will create . All are those are eligible for garbage
about session
about session  hey i want to insert userid and username of the user who have currently loggedin in servlet using prepared statement   Please visit the following link: http://www.devmanuals.com/tutorials/java/servlet
about enum - Java Beginners
about enum  hi all, please tell me about "enum" and explain with example. And its use in OOP. Thanks
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
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
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
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
Java program - Java Beginners
this given output: Example: Enter your Birthday: August 24, 1991 Your Zodiac Sign is: Virgo Your Element is: Earth Your Chinese Zodiac is: RAM I am...Java program  Dear maam/Sir, I am a 2nd year Computer
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 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
How to use dollar sign in velocity
How to use dollar sign in velocity       This Example shows you how to use dollar sign... for controlling template methods and properties. #set($sign ="+"): This is a statement
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 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 MYSQL
About MYSQL  is it possible to upload the video on mysql database   1)page.jsp: <%@ page language="java" %> <HTML> <HEAD><TITLE>Display file upload form to the user</TITLE></HEAD>
ZodiacSign with an image - Java Beginners
the user's zodiac sign together with the pictures of that sign. Ask only..."; } System.out.println("Your Zodiac sign is "+sign+"."); JLabel label1=new JLabel("Your Zodiac sign... main(String[] args) { String sign=""; String element=""; String chineseSign
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 the project
About the project       Shopping cart application is an open source project written in Java ,Struts and Hibernate. This  helps  people that want to develop
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
About Java This article is discussing about Java, which is a programming language developed by James Gosling at Sun Microsystems. Java now part of Oracle... about Java is listed below : Around 1.1 billions desktop runs Java. Every
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
About Java arrays - Java Beginners
About Java arrays  Hello.........My question is can we create a two dimensional matrix using only one for loop
About java and JDBC
About java and JDBC  Hello sir, I am doing project on java thats on swings,and using the dbase as MSSQL. what i want to know is i had created a name ,textfield ,calender(for DObirth selection), this is displayed in GUI
About java and JDBC
About java and JDBC  Hello sir, I am doing project on java thats on swings,and using the dbase as MSSQL. what i want to know is i had created a name ,textfield ,calender(for DObirth selection), this is displayed in GUI
about swing - Java Beginners
about swing  how implement a program of adding two numbers by entering two numbers separately by other user on the input dialog box and after that also show the result of the addition in other dialog box... your regardly
java prog
and outputs the day of week they were born. â?¢ Compute and output their Zodiac sign...java prog  Write a Java applet that inputs a person's date of birth (month, day, year): â?¢ Informs the person if the year of birth is a prime number
About RoseIndia.net
About RoseIndia.Net RoseIndia.Net  is global services .... Our technical teams skills include Java (J2EE) programming, ASP, C#, PHP... Framework, Web Services, Languages Java 1.5, Jakarta Torque, Ant
Java Example projects about STRUTS
Java Example projects about STRUTS  Hai... I completed MCA but i have no job in my hands. But i do some small projects about STRUTS. Please send me some example projects about STRUTS.   Please visit the following link
about java swing - Java Beginners
about java swing   How to upload the pictures and photo on the panel in java swing ,plz help thank a lot.  Hi Friend, Try the following code: import java.awt.*; import java.io.*; import javax.swing.*; import
about java swing - Java Beginners
about java swing   How to send date in data base if i use the combobox like as dd,mm,yyyy. plz reply thanx a lot  Hi Friend, Try the following code: import java.sql.*; import java.awt.*; import javax.swing.
about regular expression - Java Beginners
about regular expression  Consider the grammar G: S -> ( L ) | a L -> L, S | S a) Eliminate the left-recursion from grammar G. b) Construct a recursive descent parser for G
about image convertion - Java Beginners
about image convertion  hello , this is srujani,i want code for the below task can you help me out. task is: When the Photos are Being Uploaded The Photos must be Automatically Resized to ?Web Large? Format
about predefine classes.....
about predefine classes.....  how we know that the class used in your given examples are predefind and from where we get info. about other predefine classes. we need explanation about examples given by you for java beginners
how to genrate login id and password after submitting the sign up form?
how to genrate login id and password after submitting the sign up form?  i m working on a online voting project in that i have a user sign up form so i want 2 knw that after user submit all the details i that sign up form than
question about applet
question about applet  how to run java applet on wed browser   Hi Friend, Please visit the following link: Applet Tutorials Thanks

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.