# Java program to display astrological sign // or Zodiac sign for given date of birth

**URL:** <https://forum.codewithmosh.com/t/java-program-to-display-astrological-sign-or-zodiac-sign-for-given-date-of-birth/10159>\
**Category:** Java\
**Created:** [January 23, 2022, 12:18pm UTC](https://forum.codewithmosh.com/t/java-program-to-display-astrological-sign-or-zodiac-sign-for-given-date-of-birth/10159 "2022-01-23T12:18:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lt.Smith](https://avatars.discourse-cdn.com/v4/letter/l/3bc359/32.png) [@Lt.Smith](https://forum.codewithmosh.com/u/Lt.Smith)\
**Post date:** [January 23, 2022, 12:18pm UTC](https://forum.codewithmosh.com/t/java-program-to-display-astrological-sign-or-zodiac-sign-for-given-date-of-birth/10159/1 "2022-01-23T12:18:55Z")

</div>

Hi there ! Can anyone explain where what I’m doing wrong? After the input I want the program to print the astrological sign, but it doesn’t print anything…

Thank you in advance!

import [java.io](http://java.io).\*;  
import java.util.Scanner;

class Main {  
public static void main(String[] args) {  
Scanner myObj = new Scanner(System.in);

```
System.out.println("Enter month and day:");

// String input
String month = myObj.nextLine();

// Numerical input
int day = myObj.nextInt();

```

}  
}

class GFG {

```
static void zodiac_sign(int day, String month)
{
	String astro_sign="";
	
	// checks month and date within the
	// valid range of a specified zodiac
	if (month == "december"){
		
		if (day < 22)
		astro_sign = "Sagittarius";
		else
		astro_sign ="capricorn";
	}
		
	else if (month == "january"){
		if (day < 20)
		astro_sign = "Capricorn";
		else
		astro_sign = "aquarius";
	}
		
	else if (month == "february"){
		if (day < 19)
		astro_sign = "Aquarius";
		else
		astro_sign = "pisces";
	}
		
	else if(month == "march"){
		if (day < 21)
		astro_sign = "Pisces";
		else
		astro_sign = "aries";
	}
	else if (month == "april"){
		if (day < 20)
		astro_sign = "Aries";
		else
		astro_sign = "taurus";
	}
		
	else if (month == "may"){
		if (day < 21)
		astro_sign = "Taurus";
		else
		astro_sign = "gemini";
	}
		
	else if( month == "june"){
		if (day < 21)
		astro_sign = "Gemini";
		else
		astro_sign = "cancer";
	}
		
	else if (month == "july"){
		if (day < 23)
		astro_sign = "Cancer";
		else
		astro_sign = "leo";
	}
		
	else if( month == "august"){
		if (day < 23)
		astro_sign = "Leo";
		else
		astro_sign = "virgo";
	}
		
	else if (month == "september"){
		if (day < 23)
		astro_sign = "Virgo";
		else
		astro_sign = "libra";
	}
		
	else if (month == "october"){
		if (day < 23)
		astro_sign = "Libra";
		else
		astro_sign = "scorpio";
	}
		
	else if (month == "november"){
		if (day < 22)
		astro_sign = "scorpio";
		else
		astro_sign = "sagittarius";
	}
		
	System.out.println(astro_sign);
}
	
// Driver code
public static void main (String[] args)
{

	int day = 19;
	String month = "may";
	zodiac_sign(day, month);
		
}

```

}

---

<div class="post-metadata">

**Author:** ![JerryC](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jerryc/32/859_2.png) [@JerryC](https://forum.codewithmosh.com/u/JerryC)\
**Post date:** [January 23, 2022, 8:30pm UTC](https://forum.codewithmosh.com/t/java-program-to-display-astrological-sign-or-zodiac-sign-for-given-date-of-birth/10159/2 "2022-01-23T20:30:09Z")

</div>

REPLACE: if (month == “december”) {}  
WITH: if (month.equalsIgnoreCase(“december”) {}  
else if …  
after your last else if YOU NEED an  
else {System.out.println("Error on: " + day + “,” + month);}

---

<div class="post-metadata">

**Author:** ![Lt.Smith](https://avatars.discourse-cdn.com/v4/letter/l/3bc359/32.png) [@Lt.Smith](https://forum.codewithmosh.com/u/Lt.Smith)\
**Post date:** [January 23, 2022, 9:01pm UTC](https://forum.codewithmosh.com/t/java-program-to-display-astrological-sign-or-zodiac-sign-for-given-date-of-birth/10159/3 "2022-01-23T21:01:04Z")

</div>

Thank you @JerryC !!!

---

<div class="post-metadata">

**Author:** ![Lt.Smith](https://avatars.discourse-cdn.com/v4/letter/l/3bc359/32.png) [@Lt.Smith](https://forum.codewithmosh.com/u/Lt.Smith)\
**Post date:** [January 23, 2022, 9:08pm UTC](https://forum.codewithmosh.com/t/java-program-to-display-astrological-sign-or-zodiac-sign-for-given-date-of-birth/10159/4 "2022-01-23T21:08:03Z")

</div>

I did that, but still it doesn’t show me the astrological sign , after I input the month and day

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [August 18, 2022, 5:18am UTC](https://forum.codewithmosh.com/t/java-program-to-display-astrological-sign-or-zodiac-sign-for-given-date-of-birth/10159/5 "2022-08-18T05:18:23Z")

</div>

Your Main class never calls GFG.zodiac\_sign. If you just run the GFG class’s main method, it should print out that specific info for May 19. Otherwise please post updated code so we can see what you are currently working with (in addition to any output you may be getting).
