Coders Packet

Zodiac sign indicator using Java

By Sanjana Sakinala

The source code is given in java and it tells you about your zodiac sign based on the input you give.

Know your Zodiac sign

The source code is given in java and it tells you about your zodiac sign based on the input you give. We imported the util package in order to access the scanner class to receive the input from the user and generate the output accordingly. The main principle is using of if-else ladder in order to go through many conditions. Please use an offline compiler in order to run this program as it may be difficult to work with importing packing in online compilers.

import java.util.Scanner;
public class Zodiac{
public static void main(String[]args) {
int date,month;
Scanner sc=new Scanner(System.in);
System.out.println("Input your date:");
date=sc.nextInt();
System.out.println("Input your month:");
month=sc.nextInt();
if ((date>21 && month == 12) || (date<=19 && month== 1)){
System.out.println("Your zodiac sign is Capricorn");
}
if ((date>20 && month ==1) || (date<=18 && month == 2)){
System.out.println("Your zodiac sign is Aquarius");
}
if ((date>19 && month == 2) || (date <=20 && month == 3)){
System.out.println("Your zodiac sign is Pisces");
}
if ((date>21 && month == 3) || (date <=20 && month == 4)){
System.out.println("Your zodiac sign is Aries");
}
if ((date>21 && month == 4) || (date <=20 && month == 5)){
System.out.println("Your zodiac sign is Taurus");
}
if ((date>21 && month == 5) || (date<=20 && month == 6)){
System.out.println("Your zodiac sign is Gemini");
}
if ((date>21 && month == 6) || (date<=20 && month == 7)){
System.out.println("Your zodiac sign is Cancer");
}
if ((date>21 && month == 7) || (date<=20 && month== 8)){
System.out.println("Your zodiac sign is Leo");
}
if ((date>21 && month ==8) || (date<=22 && month == 9)){
System.out.println("Your zodiac sign is Virgo");
}
if ((date>23 && month == 9) || (date<=20 && month ==10)){
System.out.println("Your zodiac sign is Libra");
}
if ((date>21 && month == 10) || (date<=22 && month == 11)){
System.out.println("Your zodiac sign is Scorpio");
}
if ((date>23 && month == 11) || (date<=20 && month == 12)){
System.out.println("Your zodiac sign is Sagitarius");
}
else {
System.out.println("invalid");
}
}
}

Zodiac

Download project

Reviews Report

Submitted by Sanjana Sakinala (sanjana28)

Download packets of source code on Coders Packet