Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <string>
- using namespace std;
- bool isSignOf(string element[], string sign);
- int main()
- {
- //declare array for each element
- string FIRE [] = {"Aries", "Leo", "Sagittarius"};
- string EARTH [] = {"Taurus","Virgo","Capricorn"};
- string AIR [] = {"Gemini","Libra","Aquarius"};
- string WATER [] = {"Cancer","Scorpio","Pisces"};
- string sign;
- string another;
- //prompt for two signs
- cout<<"Horoscope Program which examines compatible signs."<<endl;
- cout<<"Input 2 signs."<<endl;
- cin >>sign>>another;
- //find both signs in FIRE
- if (isSignOf(FIRE, sign) && isSignOf(FIRE, another))
- cout<<sign<<" and "<<another<<" are compatible Fire signs.";
- //find both signs in EARTH
- else if (isSignOf(EARTH, sign) && isSignOf(EARTH, another))
- cout<<sign<<" and "<<another<<" are compatible Earth signs.";
- //find both signs in AIR
- else if (isSignOf(AIR, sign) && isSignOf(AIR, another))
- cout<<sign<<" and "<<another<<"are compatible Air signs.";
- //find both signs in WATER
- else if (isSignOf(WATER, sign) && isSignOf(WATER, another))
- cout<<sign<<" and "<<another<<" are compatible Water signs.";
- //if not found in any of the four elements, then not compatible
- else
- cout<<sign<<" and "<<another<<" are not compatible signs.";
- //system("pause");
- return 0;
- }
- //function to find a sign in an element
- //if found return true, otherwise return false
- bool isSignOf(string element[], string sign)
- {
- for (int i=0; i<3; i++)
- {
- if (element[i] == sign)
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement