if statement with multiple conditions

I'm trying to create a program that outputs your zodiac animal based on the year you're born in. I've tried a few things but no matter what year I enter, the outputted message is always the first cout message.



This part of the code I'm try to fix:

if (bornYear>=1900 && bornYear<=2019)
{
if (bornYear==1924||1936||1948||1960||1972||1984||1996||2008)
cout<<"Your lucky Chinese Zodiac Animal is Pig\nYour personailty could be quick-witted, resourceful, versatile and kind.";
else if (bornYear==1925||1937||1949||1961||1973||1985||1997||2009)
cout<< "Your lucky Chinese Zodiac Animal is Ox\nYour personailty could be diligent, dependable, strong and determined.";
else if (bornYear==1926||1938||1950||1962||1974||1986||1998||2010)
cout<< "Your lucky Chinese Zodiac Animal is Tiger\nYour personailty could be Brave, confident and competitive.";

}

Thanks
Last edited on
if (bornYear == 1924 || bornYear == 1936 || bornYear == 1948 || bornYear == 1960 || bornYear == 1972 || bornYear == 1984 || bornYear == 1996 || bornYear == 2008)
// if (bornYear==1924||1936||1948||1960||1972||1984||1996||2008)
should be
1
2
if ( bornYear==1924 || bornYear==1936 || bornYear==1948 || bornYear==1960 ||  
     bornYear==1972 || bornYear==1984 || bornYear==1996 || bornYear==2008 )

etc.

This is simpler:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>

int main()
{
    const int BASE_YEAR = 1924 ;

    int year ;
    std::cout << "what year were you born in? " ;
    std::cin >> year ;

    if( year < BASE_YEAR ) std::cout << "you are too old\n" ;

    else if( year > 2019 ) std::cout << "wait till you are born\n" ;

    else
    {
        const int delta = year - BASE_YEAR ;

        switch(delta%12)
        {
            case 0 : // year is one of 1924, 1936, 1948, 1960, 1972, 1984, 1996, 2008

                std::cout << "Your lucky Chinese Zodiac Animal is Pig\n"
                             "Your personality could be quick-witted, resourceful, versatile and kind.\n" ;
                break ;

            case 1 : // year is one of 1925, 1937, 1949, 1961, 1973, 1985, 1997, 2009

                std::cout << "Your lucky Chinese Zodiac Animal is Ox\n"
                             "Your personality could be diligent, dependable, strong and determined.\n" ;
                break ;

            // etc. 
        }
    }
}
Topic archived. No new replies allowed.