Menu
Question Index
...

Write a program to identify the zodiac sign of a given date of birth.
NOTE: While passing the month to the GregorianCalendar, it will start from 0 and go till 11.
Assume that the zodiac sign date ranges are as listed below.

Aries[Mar 21–Apr 19], Taurus[Apr 20–May 20], Gemini[May 21–June 20], Cancer[June 21–July 22], Leo[July 23–Aug 22], Virgo[Aug 23–Sept 22], Libra[Sept 23–Oct 22], Scorpio[Oct 23–Nov 21], Sagittarius[Nov 22–Dec 21], Capricorn[Dec 22–Jan 19], Aquarius[Jan 20–Feb 18], Pisces[Feb 19–Mar 20]

Input (Calendar) Output (String)
1990-12-14 Sagittarius
22-8-2007 Leo
22-6-2001 Cancer
10-9-1990 Virgo
20-4-2008 Taurus


import java.util.*;
import java.text.*;
class IdentifyZodiacSign
{
    public static void main(String s[])
    {
        Calendar cal = new GregorianCalendar();
        cal.set(1990, 11, 14);
        System.out.println("Zodiac sign of '1990 - 11- 14' is " + getTheZodiacSign(cal));

    }


    public static String getTheZodiacSign(Calendar cal) {
    }

}

Doubts

Problems

Topic: Java GregorianCalendar

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App