Using Borland C++ 3.0

Here's my code:

#include<iostream.h>
#include<conio.h>

int main()

{
 int m,d;
 int i=0;

clrscr();

 cout<<"\nEnter Birthday month: ";
 cin>>m;
 cout<<"\nEnter Birthday day: ";
 cin>>d;
 cout<<"\n";


  {
      if(m==3 && d>=21)
       cout<<"ARIES!";
      else if (m==4 && d<=20)
       cout<<"ARIES!";

      else if(m==4 && d>=21)
       cout<<"TAURUS!";
      else if(m==5 && d<=21)
       cout<<"TAURUS!";

      else if(m==5 && d>=22)
       cout<<"GEMINI!";
      else if(m==6 && d<=21)
       cout<<"GEMINI!";

      else if(m==6 && d>=22)
       cout<<"CANCER!";
      else if(m==7 && d<=22)
       cout<<"CANCER!";

      else if(m==7 && d>=23)
       cout<<"LEO!";
      else if(m==8 && d<=21)
       cout<<"LEO!";

      else if(m==8 && d>=22)
       cout<<"VIRGO!";
      else if(m==9 && d<=23)
       cout<<"VIRGO!";

      else if(m==9 && d>=24)
       cout<<"LIBRA!";
      else if(m==10 && d<=23)
       cout<<"LIBRA!";

      else if(m==10 && d>=24)
       cout<<"SCORPIO!";
      else if(m==11 && d<=22)
       cout<<"SCORPIO!";

      else if(m==11 && d>=23)
       cout<<"SAGITTARIUS!";
      else if(m==12 && d<=22)
       cout<<"SAGITTARIUS!";

      else if(m==12 && d>=23)
       cout<<"CAPRICORN!";
      else if(m==1 && d<=20)
       cout<<"CAPRICORN!";

      else if(m==1 && d>=21)
       cout<<"AQUARIUS!";
      else if(m==2 && d<=19)
       cout<<"AQUARIUS!";

      else if(m==2 && d>=20)
       cout<<"PISCES!";
      else if(m==3 && d<=20)
      cout<<"PISCES!";

      else
	cout<<"\nEither day or month value is invalid.";

      gotoxy(35,15);
      cout<<"Try again ? ";

     if(getche()=='y')
     {
	getche();
	i=0;
     } else
     {
	i=1;
     }
     if (i==0)
     {
	gotoxy(45,2);
	cout<<"Enter Birthday month: ";
	cin>>m;
	gotoxy(45,4);
	cout<<"Enter Birthday day: ";
	cin>>d;


   gotoxy(45,6);
     if(m==3 && d>=21)
       cout<<"ARIES!";
     else if (m==4 && d<=20)
       cout<<"ARIES!";

      else if(m==4 && d>=21)
       cout<<"TAURUS!";

      else if(m==5 && d<=21)
       cout<<"TAURUS!";

      else if(m==5 && d>=22)
	  cout<<"GEMINI!";

      else if(m==6 && d<=21)
       cout<<"GEMINI!";

      else if(m==6 && d>=22)
       cout<<"CANCER!";
      else if(m==7 && d<=22)
       cout<<"CANCER!";

      else if(m==7 && d>=23)
       cout<<"LEO!";
      else if(m==8 && d<=21)
       cout<<"LEO!";

      else if(m==8 && d>=22)
       cout<<"VIRGO!";
      else if(m==9 && d<=23)
       cout<<"VIRGO!";

      else if(m==9 && d>=24)
       cout<<"LIBRA!";
      else if(m==10 && d<=23)
       cout<<"LIBRA!";

      else if(m==10 && d>=24)
       cout<<"SCORPIO!";
      else if(m==11 && d<=22)
       cout<<"SCORPIO!";

      else if(m==11 && d>=23)
       cout<<"SAGITTARIUS!";
      else if(m==12 && d<=22)
       cout<<"SAGITTARIUS!";

      else if(m==12 && d>=23)
       cout<<"CAPRICORN!";
      else if(m==1 && d<=20)
       cout<<"CAPRICORN!";

      else if(m==1 && d>=21)
       cout<<"AQUARIUS!";
      else if(m==2 && d<=19)
       cout<<"AQUARIUS!";

      else if(m==2 && d>=20)
       cout<<"PISCES!";
      else if(m==3 && d<=20)
      cout<<"PISCES!";


      else
	cout<<"\nEither day or month value is invalid.";


     } else {


     }
     getche();
   return 0;
  }
}

My problem is how to compare outputs and create a message.

E.g If both element message (Element is Water), a message will display saying

COMPATIBLE. If not the same element, "NOT COMPATIBLE". Of course, still basing on the

range of months and days

I really don't know how to do that cuz it's on the cout<< function.

Thanks in adance

You could assign each star sign a number then store each of the two choices in a variable and compare them afterwards. I would also break your code into pieces by making some functions that work out the star sign and do the comparing. Like this:

#include <iostream>
#include <string>

/* Function prototypes for your functions */
int getStarSign(int month, int day);
string signToString(int sign);
bool checkCompatibility(int sign1, int sign2);

using namespace std;

int main()
{
   int starSign1 = -1; starSign2 = -1;
   int month, day;

   cout << "Enter month: ";
   cin >> month;
   cout << "Enter day: ";
   cin >> day;

   /* Put code to check the month and day make sense here */
   
   /* Get the first star sign */
   starSign1 = getStarSign(month,day);
   
   /* Now repeat for the second date */

   cout << "Enter month: ";
   cin >> month;
   cout << "Enter day: ";
   cin >> day;

   /* Put code to check the month and day make sense here */
   
   /* Get the next star sign */
   starSign2 = getStarSign(month,day);

   /* Now output some thing to the screen */
   cout << "The star signs were: " << signToString(starSign1) << " and " << signToString(starSign2) << endl; 
   cout << "Star signs are " << ( checkCompatibility(starSign1, starSign2) ? "compatible!" : "not compatible :o(" ) << endl;
   
   return 0;
}

/* Add code for functions here */

So, now you just need the code for the functions. Have a go at that and see how you get on.

Also, Borland C++ 3.0 is a really, really old compiler. As a result of this, you have used several very non-standard practices, such as using gotoxy() and conio.h . You should consider using something more modern, such as Code::blocks, on Windows.

commented: good example code +6

Thanks sir, this works.

Uhm yeah, i'm using DevC++ 5.0 (newbie on using this) but use Borland sometimes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.