Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a C++ Expert!

Join 244,303 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 786 people online right now. Registration is fast and FREE... Join Now!




remove error

 
Reply to this topicStart new topic

remove error

ankitmohan91
29 Dec, 2008 - 06:55 AM
Post #1

New D.I.C Head
*

Joined: 5 Nov, 2008
Posts: 7

plzzzzzzz remove the error present in the program
CODE
#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<iomanip.h>
class fortune
{
public:
int printfortune(int Randomize);
};

class process
{
int year,mon,date,rem,year1,mon1,birth_answer;
char month[20];
public:
void enterdate();
void display();
int thirtyone(char *month,int &date);
int thirty(char *month,int &date);
int february(char *month,int &date);

void checkmain();
protected:
char sunsign[20];
char month1[20];
int date1;
}p;
class lucky:public process
{
      void aquarius ();
      void pisces ();      
      void aries ();
      void taurus ();
      void gemini ();
      void cancer ();
      void leo ();
      void virgo ();
      void libra ();
      void scorpio ();
      void sagittarius ();
      void capricorn ();
      public:
      void ProcessSign(char *month,int &date);



}l;

void process::checkmain()
{
    cout<<"  First of all I need the current date ..."<<"  ";
    cout<<"  Year :";
    cin>>year;
    if(year<=0||year>10000)
    {
          do
          {
               cout<<"Invalid input for year !"<<"  ";                    
               cout<<"Please enter the year correctly :"<<"  ";
               cin>>year;
          }while(year<0||year>10000);
    }
    cout<<"Month :";
    cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
        cout<<"\t***************************************************************\n";
         cout<<"\t*                                                             *\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t*      1) January                             7) July         *\n";
     cout<<"\t*      2) February                            8) August       *\n";
     cout<<"\t*      3) March                               9) September    *\n";
     cout<<"\t*      4) April                              10) October      *\n";
     cout<<"\t*      5) May                                11) November     *\n";
     cout<<"\t*      6) June                               12) December     *\n";
     cout<<"\t***************************************************************\n";
     cout<<"\n\t\t        What is todays date?";
     cout<<"\n\t\tEnter the month of todays date ie: january \n\t\t";
     gets(month);
     cout<<"\n\t\tenter the month(in numeric form)ie: 1\n\t\t";
         cin>>mon;

    if(mon<=0||mon>12)
    {
          do
          {
           cout<<"Invalid input for month !"<<"  ";
           cout<<"Again enter the month :"<<"    ";
           gets(month);
           cin>>mon;
          }while(mon<0||mon>12);
    }
    cout<<"Date :";
    switch(mon)
    {
          case 1:
          case 3:
          case 5:
         case 7:
          case 8:
          case 10:
          case 12:{

               thirtyone(month,date);
                   break;
                  }
          case 2:{
             thirty(month,date);
                  break;
                 }
        default:{
               thirty(month, date);
                  break;
                 }
    }
    display();
    enterdate();
    l.ProcessSign(month1,date1);

}


void lucky::ProcessSign(char *month1,int &date1)
    {
        //cout << "\tYour Sign is : ";
        if (!strcmpi (month1, "january")&& date1>=21)
                {
            strcpy(sunsign,"Aquarius" );
                        aquarius();
                }

        if (!strcmpi (month1, "february")&& date1<=19)
                {
            strcpy(sunsign,"Aquarius ");
            aquarius();
                }
        if (!strcmpi (month1, "february")&& date1>=20)
                {
            strcpy(sunsign,"pisces ");
            pisces();
                }
        if (!strcmpi (month1, "march")&& date1<=20)
                {
            strcpy(sunsign,"Pisces ");
            pisces();
        }

        if (!strcmpi (month1, "march")&& date1>=21)
                {
            strcpy(sunsign,"Aries ");
            aries();
                }
        if (!strcmpi (month1, "april")&& date1<=20)
        {
            strcpy(sunsign,"Aries ");
            aries();
                }
        if (!strcmpi (month1, "april")&& date1>=21)
                {
            strcpy(sunsign,"Taurus ");
            taurus();
                }
        if (!strcmpi (month1, "may")&& date1<=21)
                {
            strcpy(sunsign,"Taurus ");
            taurus();
                }
        if (!strcmpi (month1, "may")&& date1>=22)
                {
            strcpy(sunsign,"Gemini");
            gemini();
                }
        if (!strcmpi (month1, "june")&& date1<=21)
                {
            strcpy(sunsign,"Gemini");
            gemini();
                }
        if (!strcmpi (month1, "june")&& date1>=22)
                {
            strcpy(sunsign,"Cancer");
            cancer();
                }
        if (!strcmpi (month1, "july")&& date1<=22)
                {
            strcpy(sunsign,"Cancer ");
            cancer();
                }
        if (!strcmpi (month1, "july")&& date1>=23)
                {
            strcpy(sunsign,"Leo");
                        leo();
                }
        if (!strcmpi (month1, "august")&& date1<=22)
                {
            strcpy(sunsign,"Leo");
            leo();

        if (!strcmpi (month1, "august")&& date1>=23)
                {
            strcpy(sunsign,"Virgo ");
            virgo();
                }
        if (!strcmpi (month1, "september")&& date1<=23)
                {
            strcpy(sunsign,"Virgo");
            virgo();
                }
        if (!strcmpi (month1, "september")&& date1>=24)
                {
            strcpy(sunsign,"Libra");
            libra();
                }
        if (!strcmpi (month1, "october")&& date1<=23)
                {
            strcpy(sunsign,"Libra ");                    
                }        libra();
        if (!strcmpi (month1, "october")&& date1>=24)
                {
            strcpy(sunsign,"Scorpio");
            scorpio();
                }
        if (!strcmpi (month1, "november")&& date1<=22)

        strcpy(sunsign,"Scorpio ");

        if (!strcmpi (month1, "november")&& date1>=23)
                {
            strcpy(sunsign,"Sagittarius ");
            sagittarius();
                }
        if (!strcmpi (month1, "december")&& date1<=21)
                {
            strcpy(sunsign,"Sagittarius ");
            sagittarius();
                }
        if (!strcmpi (month1, "december")&& date1>=22)
                {
            strcpy(sunsign,"Capricorn ");
            capricorn();
                }
        if (!strcmpi (month1, "january")&& date1<=20)
                {
            strcpy(sunsign,"Capricorn ");
            capricorn();
                }
        cout<<"your sunsign:";
                puts(sunsign);
    }



void process::display()
{

clrscr();
cout<<"Hello....   It's ";
cout<<date;
rem=date%10;
switch(date)
{
  case 11:
  case 12:
  case 13:
  case 14:
  case 15:
  case 16:
  case 17:
  case 18:
  case 19:
  case 20:{
           cout<<"th ";
           goto over;
          }
}
switch(rem)
{
  case 1:{
          cout<<"st ";
          break;
         }
  case 2:{
          cout<<"nd ";
          break;
         }
  case 3:{
          cout<<"rd ";
          break;
         }
default:{
          cout<<"th ";
          break;
         }
}
over:
switch(mon)
{
  case 1:{
          cout<<"January , ";
          break;
         }
  case 2:{
          cout<<"February , ";
          break;
         }
  case 3:{
          cout<<"March , ";
          break;
         }
  case 4:{
          cout<<"April , ";
          break;
         }
  case 5:{
          cout<<"May , ";
          break;
         }
  case 6:{
          cout<<"June , ";
          break;
         }
  case 7:{
          cout<<"July , ";
          break;
         }
  case 8:{
          cout<<"August , ";
          break;
         }
  case 9:{
          cout<<"September , ";
          break;
         }
case 10:{
          cout<<"October , ";
      break;
         }

case 11:{
          cout<<"November , ";
          break;
         }
case 12:{
          cout<<"December , ";
          break;
         }
}
cout<<year<<"";

}


int process::thirtyone (char *month,int &date)
     {
     cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t*                                                             *\n";
     cout<<setw(9)<<"*"<<setw(34)<<month<<setw(29)<<                       "*\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t*            1)    2)    3)    4)    5)    6)    7)           *\n";
     cout<<"\t*            8)    9)   10)   11)   12)   13)   14)           *\n";
     cout<<"\t*           15)   16)   17)   18)   19)   20)   21)           *\n";
     cout<<"\t*           22)   23)   24)   25)   26)   27)   28)           *\n";
     cout<<"\t*           29)   30)   31)                                   *\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t\tenter the current date IE: 1 -> 31\n \t\t";
     cin>>date;

     cin.clear();
     cin.ignore();

     while (date<1 || date >31)
     {
     cout<<"\t\tThat is not a valid day for\t" << month<<"\n\t\t";
     cin>>date;
     }
     return(date);
     }


int process::thirty (char *month,int &date)
     {
     cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t*                                                             *\n";
     cout<<setw(9)<<"*"<<setw(34)<<month<<setw(29)<<                       "*\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t*            1)    2)    3)    4)    5)    6)    7)           *\n";
     cout<<"\t*            8)    9)   10)   11)   12)   13)   14)           *\n";
     cout<<"\t*           15)   16)   17)   18)   19)   20)   21)           *\n";
     cout<<"\t*           22)   23)   24)   25)   26)   27)   28)           *\n";
     cout<<"\t*           29)   30)                                         *\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t\tenter the current date IE: 1 -> 30\n \t\t";
     cin>>date;

    cin.clear();
     cin.ignore();

      while (date<1 || date >30)
     {
     cout<<"\t\tThat is not a valid day for\t" << month<<"\n\t\t";
     cin>>date;
     }
     return(date);
     }


  int process:: february (char *month,int &date)
     {
     cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t*                                                             *\n";
     cout<<setw(9)<<"*"<<setw(34)<<month<<setw(29)<<                       "*\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t*            1)    2)    3)    4)    5)    6)    7)           *\n";
     cout<<"\t*            8)    9)   10)   11)   12)   13)   14)           *\n";
     cout<<"\t*           15)   16)   17)   18)   19)   20)   21)           *\n";
     cout<<"\t*           22)   23)   24)   25)   26)   27)   28)           *\n";
     cout<<"\t*           29)                                               *\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t\tenter the current date IE: 1 -> 29\n \t\t";
     cin>>date1;

    cin.clear();
     cin.ignore();
     if(year%4==0)
          {
           while(date<0||date>29) //for leap year
           {
            cout<<"Invalid date !"<<"  ";
            cout<<"Again enter the date :"<<"  ";
            cin>>date;
           }
      }
          else
          {
           while(date<0||date>28) //for non-leap year
           {
            cout<<"Invalid date !"<<"   ";
            cout<<"Again enter the date :"<<"   ";
            cin>>date;
           }
      }
     }














void process::enterdate()
{
    clreol();
    cout<<"\n\n *** Date of birth ***"<<"\n";
    clreol();
    cout<<"\nYear  : ";
    clreol();
    clreol();
    cin>>year1;
    while(year1>year)  //to ensure that the year of birth
    {                                           //gets entered correctly
          clreol();
          cout<<"\aInvalid input for year !!!";
          cout<<"\nThe date of birth cannot be after the current system date !!! ";
          cout<<"\nPlease enter the year correctly : ";
          clreol();
          cin>>year1;
          cout<<"\n";
    }
    while(year1<1000)
    {
          clreol();
        cout<<"Invalid input for year !!! ";
          clreol();
          cout<<"\nThe year of birth must be of 4 digits!!!";
          clreol();
          cout<<"\nPlease enter the year correctly : \a";
          clreol();
          cin>>year1;
          cout<<"\n";
    }
    while(year1<1900)
    {
          clreol();
          cout<<"\a\nAre you sure (Y/N) ? ";
          cin>>birth_answer;
          cout<<"\n";
          while(birth_answer!='Y'&&birth_answer!='y'&&birth_answer!='N'&&birth_answer!='n')
          {
               clreol();
               cout<<"\a\nInvalid input !!! "<<"\n";
               clreol();
               cout<<"Please enter a correct option (Y/N) : ";
               cout<<"\n";
               clreol();
               cin>>birth_answer;
          }
      if(birth_answer=='n'||birth_answer=='N')
          {
               clreol();
               cout<<"\nPlease enter the year again : ";
               clreol();
            cin>>year1;
               clreol();
               while(year1>year)
               {
                    clreol();
                    cout<<"Invalid input for year !!! ";
                    clreol();
                    cout<<"\nThe date of birth cannot be after the current system date !!! ";
                    clreol();
                    cout<<"\nPlease enter the year correctly : \a";
                    clreol();
                    cin>>year1;
                    cout<<"\n";
               }
               while(year1<1000)
               {
                    clreol();
                    cout<<"\aInvalid input for year !!! ";
                    clreol();
                    cout<<"\nThe year of birth must be of 4 digits!!!\a";
                    clreol();
                    cout<<"\nPlease enter the year correctly : ";
                    clreol();
                    cin>>year1;
                    cout<<"\n";
            }
                }
                                //end of inner while
          while(birth_answer=='y'||birth_answer=='Y')
          {
           goto jump;
          }                     //end of inner while
    }                      //end of outer while
    jump:
    clreol();
    cout<<"Month : ";
    cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t*                                                             *\n";
     cout<<"\t***************************************************************\n";
     cout<<"\t*      1) January                             7) July         *\n";
     cout<<"\t*      2) February                            8) August       *\n";
     cout<<"\t*      3) March                               9) September    *\n";
     cout<<"\t*      4) April                              10) October      *\n";
     cout<<"\t*      5) May                                11) November     *\n";
     cout<<"\t*      6) June                               12) December     *\n";
     cout<<"\t***************************************************************\n";
     cout<<"\n\t\t        What is todays date?";
     cout<<"\n\t\tEnter the month of todays date ie: january \n\t\t";
     gets(month1);
     cout<<"\n\t\tenter the month(in numeric form)ie: 1\n\t\t";
         cin>>mon1;

    if(mon1<=0||mon1>12)
    {
          do
          {
               cout<<"Invalid input for month !"<<"  ";
               cout<<"Again enter the month :"<<"    ";
               gets(month1);
               cin>>mon1;
          }while(mon1<0||mon1>12);
    }

    while(mon1<=0||mon1>12)
    {
          clreol();
          cout<<"\a\nInvalid input for month !!!"<<"\n";
          cout<<"Again enter the month : ";
          clreol();
          clreol();
          cin>>month1;
    }
    cout<<"Date  : ";
    clreol();
    switch(mon1)
    {
          case 1:
          case 3:
          case 5:
          case 7:
          case 8:
          case 10:
        case 12:
        {
                   cin>>date1;           //for months with 31 days
                   while(date1<1||date1>31)
                   {
                        clreol();
                        cout<<"\aInvalid date !!!"<<"\n";
                        cout<<"Again enter the date : ";
                        clreol();
                        cin>>date1;
                        cout<<"\n";
                   }
                   break;
             }
        case 2:
        {                                  //for february
                  cin>>date1;
                  if(year1%4==0)
                  {
                       while(date1<0||date1>29)  //for leap year
                       {
                            clreol();
          &n

User is offlineProfile CardPM
+Quote Post


Amadeus
RE: Remove Error
29 Dec, 2008 - 07:21 AM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,977



Thanked: 116 times
Dream Kudos: 25
My Contributions
Please post the exact error messages.
User is online!Profile CardPM
+Quote Post

OliveOyl3471
RE: Remove Error
29 Dec, 2008 - 09:23 AM
Post #3

D.I.C Aficionada
Group Icon

Joined: 11 Jul, 2007
Posts: 3,797



Thanked: 54 times
Dream Kudos: 675
My Contributions
Here's a hint:
Attempt to compile the code and read the error messages. There are several (at least with my compiler there were)

Also add a main() function.

I hope this helps you! smile.gif
User is offlineProfile CardPM
+Quote Post

ankitmohan91
RE: Remove Error
29 Dec, 2008 - 10:19 PM
Post #4

New D.I.C Head
*

Joined: 5 Nov, 2008
Posts: 7

i am not able to copy the whole code
User is offlineProfile CardPM
+Quote Post

Hyper
RE: Remove Error
29 Dec, 2008 - 11:29 PM
Post #5

Banned
*****

Joined: 15 Oct, 2008
Posts: 2,129



Thanked: 87 times
Dream Kudos: 425
My Contributions
QUOTE(ankitmohan91 @ 29 Dec, 2008 - 10:19 PM) *

i am not able to copy the whole code


Post the file(s) here on the site (File Attachments are on the bottom end) so we can see the *entire* project the way you wrote it.
User is offlineProfile CardPM
+Quote Post

ankitmohan91
RE: Remove Error
30 Dec, 2008 - 07:31 AM
Post #6

New D.I.C Head
*

Joined: 5 Nov, 2008
Posts: 7

HERE IS THE FILE


Attached File(s)
Attached File  ANKIT1.txt ( 30.6k ) Number of downloads: 4
User is offlineProfile CardPM
+Quote Post

JackOfAllTrades
RE: Remove Error
30 Dec, 2008 - 08:44 AM
Post #7

Cantankerous Old Fart
Group Icon

Joined: 23 Aug, 2008
Posts: 3,055



Thanked: 270 times
Dream Kudos: 50
Expert In: Nothing. Well, nothing relevant here anyway. ;)

My Contributions
Other than the fact that you're using some antiquated compiler, as we so often see here, and using gets()...

You're missing a } to close the lucky::ProcessSign() method.

You declared all your sign methods with lower case names, then defined them using upper case, and called them using lower case. Pick a case a go with it.

You have an unneeded semicolon following the } bracket of main, and an unneeded }; at the end of the program.

You need to return a value from process:february().

Next time, learn how to read your compiler messages, or you're never going to be a programmer.
User is online!Profile CardPM
+Quote Post

Hyper
RE: Remove Error
30 Dec, 2008 - 12:41 PM
Post #8

Banned
*****

Joined: 15 Oct, 2008
Posts: 2,129



Thanked: 87 times
Dream Kudos: 425
My Contributions
QUOTE(JackOfAllTrades @ 30 Dec, 2008 - 08:44 AM) *

Other than the fact that you're using some antiquated compiler, as we so often see here, and using gets()...

You're missing a } to close the lucky::ProcessSign() method.

You declared all your sign methods with lower case names, then defined them using upper case, and called them using lower case. Pick a case a go with it.

You have an unneeded semicolon following the } bracket of main, and an unneeded }; at the end of the program.

You need to return a value from process:february().

Next time, learn how to read your compiler messages, or you're never going to be a programmer.


JackOfAllTrades, Whether you know how to program or not, being a dickface won't let you hold a job as a programmer.
Learn mannerism or you'll never get, keep, and hold a job (as a programmer).
User is offlineProfile CardPM
+Quote Post

ankitmohan91
RE: Remove Error
2 Jan, 2009 - 10:24 AM
Post #9

New D.I.C Head
*

Joined: 5 Nov, 2008
Posts: 7

thanks for the previous suggestion
i have included file handling in that program the program is running properly but it is not giving proper results
like the sunsign is not correct
while reading from file the loop goes infinite
while returning abt fortune only libra is returned
plzz help me out


Attached File(s)
Attached File  Q.txt ( 39.93k ) Number of downloads: 1
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 7/4/09 06:06PM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month