Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners About zodiac sign in java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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



Advertisement
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
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
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 java
about java  how to get the value from the user like c, c++ program pls explain with example for me
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
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 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
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
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
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 enum - Java Beginners
about enum  hi all, please tell me about "enum" and explain with example. And its use in OOP. Thanks
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 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 Java - Java Interview Questions
About Java  what is edition of java? versions of weblogic? what r the webserver applications used in your application
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
Questions about Java's String pool
Questions about Java's String pool  Questions about Java's String pool
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 Java arrays - Java Beginners
About Java arrays  Hello.........My question is can we create a two dimensional matrix using only one for loop
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 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 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
Advertisements
 

 

 

DMCA.com