SHARE
TWEET

Untitled

a guest Mar 19th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. bool isSignOf(string element[], string sign);
  6. int main()
  7. {
  8.     //declare array for each element
  9.     string FIRE [] = {"Aries", "Leo", "Sagittarius"};
  10.     string EARTH [] = {"Taurus","Virgo","Capricorn"};
  11.     string AIR  [] = {"Gemini","Libra","Aquarius"};
  12.     string WATER [] = {"Cancer","Scorpio","Pisces"};
  13.  
  14.     string sign;
  15.     string another;
  16.  
  17.     //prompt for two signs
  18.     cout<<"Horoscope Program which examines compatible signs."<<endl;
  19.         cout<<"Input 2 signs."<<endl;
  20.     cin >>sign>>another;
  21.  
  22.     //find both signs in FIRE
  23.     if (isSignOf(FIRE, sign) && isSignOf(FIRE, another))
  24.         cout<<sign<<" and "<<another<<" are compatible Fire signs.";
  25.     //find both signs in EARTH
  26.     else if (isSignOf(EARTH, sign) && isSignOf(EARTH, another))
  27.         cout<<sign<<" and "<<another<<" are compatible Earth signs.";
  28.     //find both signs in AIR
  29.     else if (isSignOf(AIR, sign) && isSignOf(AIR, another))
  30.         cout<<sign<<" and "<<another<<"are compatible Air signs.";
  31.     //find both signs in WATER
  32.     else if (isSignOf(WATER, sign) && isSignOf(WATER, another))
  33.         cout<<sign<<" and "<<another<<" are compatible Water signs.";
  34.     //if not found in any of the four elements, then not compatible
  35.     else
  36.         cout<<sign<<" and "<<another<<" are not compatible signs.";
  37.     //system("pause");
  38.     return 0;
  39. }
  40.  
  41. //function to find a sign in an element
  42. //if found return true, otherwise return false
  43. bool isSignOf(string element[], string sign)
  44. {
  45.     for (int i=0; i<3; i++)
  46.     {
  47.         if (element[i] == sign)
  48.             return true;
  49.     }
  50.     return false;
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top