1 Replies - 100 Views - Last Post: 14 September 2012 - 11:51 AM Rate Topic: -----

#1 THE.OS  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 14-September 12

Tense.Teller(getting a weird error).

Posted 14 September 2012 - 11:45 AM

#include <iostream>
#include <string>
using namespace std;
string Pi="it in present indefinite tense",Pc="it in present continuous tense",Pp="it in present perfect tense",Ppc="its in present perfect continuous tence",Pai="its in past indefinite tense",Pac="its in past continuous tense",Pap="its in past perfect tense",Papc="it in past perfect continuous tense",Fi="its in future indefinite tense",Fc="its in future continuous tense",Fp="its in future perfect tense",Fpc="its in future perfect continuous tense";
string PITense(string a)
                                                   {


string PIArray[2]={"do","does"};
if(a.find(PIArray[0])!=string::npos)               {
return Pi;
                                                 }     
else                                               {
if(a.find(PIArray[1])!=string::npos)
                                                   {
return Pi;
                                                 }
                                                 }
                                                 }
string PCTense(string a)                           {
string PCArray[3]={"is","am","are"};
if(a.find(PCArray[0])!=string::npos)               {
return Pc;
                                                 }
else                                               {
if(a.find(PCArray[1])!=string::npos)               {
return Pc;
                                                 }
else                                               {
if(a.find(PCArray[2])!=string::npos)               {
return Pc;
                                                 }          
                                                 }
                                                 }  
                                                 }
string PPTense(string a)                           {
string PPArray[2]={"has","have"};
if(a.find(PPArray[0])!=string::npos)               {
return Pp;
                                                 }
else                                               {
if(a.find(PPArray[1])!=string::npos)               {
return Pp;
                                                 } 
                                                 }
                                                 }
string PPCTense(string a)                          {
string PPCArray[2]={"has been","have been"};
if(a.find(PPCArray[0])!=string::npos)              {
return Ppc;
                                                 }
else                                               {
if(a.find(PPCArray[1])!=string::npos)              {
return Ppc;
                                                 }
                                                 }
                                                 }
string PaITense(string a)                          {
string PaITense[1]={"did"};
if(a.find(PaITense[1])!=string::npos)              {
return Pai;
                                                 }
else if(a.find(PaITense[1])==string::npos)         {
return Pai;
                                                 }
                                                 }
string PACTense(string a)                          {
string PACTense[2]={"was","were"};
if(a.find(PACTense[0])!=string::npos)              {
return Pac;
                                                 }
else                                               { 
if(a.find(PACTense[1])!=string::npos)              {
return Pac;
                                                 }
                                                 }
                                                 }
string PaPTense(string a)                          {
string PAPTense[1]={"had"};
if(a.find(PAPTense[0])!=string::npos)              {
return Pap;
                                                 }
                                                 }
string PaPCTense(string a)                         {
string PAPCTense[1]={"had been"};
if(a.find(PAPCTense[0])!=string::npos)             {
return Papc
                                                 }
                                                 }
string FiTense(string a)                           {
string FITense[2]={"shall","will"};
if(a.find(FITense[0])!=string::npos)               {
returm Fi;
                                                 }
else                                               {
if(a.find(FITense[1])!=string::npos)               {
return Fi;
                                                 }
                                                 }
                                                 }
string FcTense(string a)                           {
string FCTense[2]={"shall be","will be"};
if(a.find(FCTense[0])!=string::npos)               {
return Fc;
                                                 }
else                                               {
if(a.find(FCTense[1])!=string::npos)               {
return Fc;
                                                 }
                                                 }
                                                 }
string FpTense(string a)                           {
string FPTense[2]={"will have","shall have"};
if(a.find(FPTense[0])!=string::npos)               {
return Fp;
                                                 }
else                                               {
if(a.find(FPTense[1])!=string::npos)               {
return Fp;
                                                 }
                                                 }
                                                 }
string FpcTense(string a)                          {
string FPCTense[2]={"will have been","shall have been"};
if(a.find(FPCTense[0])!=string::npos)              {
return Fpc;
                                                 }
else                                               {
if(a.find(FPCTense[1])!=string::npos)              {
return Fpc; 
                                                 }
                                                 }
                                                 }
string AcProgram()                                 {
string c;
getline (cin,c);
if(c.find("do"||"does")!=string::npos)             {
return PITense(c);
                                                 }
else                                               {
if(c.find("is"||"am"||"are")!=string::npos)        {
return PCTense(c);
                                                 }
else{if(c.find(" has "||" have ")!=string::npos)
                                                   {
return PPTense(c);
                                                 }
else                                               {
if(c.find("has been"||"have been")!=string::npos)  {
return PPCTense(c);
                                                 }
else                                               {
if(c.find("did")!=string::npos)                    {
return PaITense(c);
                                                 }
else                                               {
if(c.find("was"||"were")!=string::npos)            {
return PACTense(c);
                                                 }
else                                               {
if(c.find(" had ")!=string::npos)                  {
return PaPTense(c);
                                                 }
else                                               {
if(c.find("had been")!=string::npos)               {
return PaPCTense(c);
                                                 }
else                                               {
if(c.find(" shall "||" will ")!=string::npos)      {
return FiTense(c);
                                                 }
else                                               {
if(c.find("shall be"||"will be")!=string::npos)    {
return FcTense(c);
                                                 }
else                                               {
if(c.find("shall have"||"will have")!=string::npos){
return FpTense(c);
                                                 }
else                                               {
if(c.find("will have been"||"shall have been"))    {
return FpcTense(c);
                                                 }
                                                 }
                                                 }
                                                 }
                                                 }
                                                 }
                                                 }
                                                 }
                                                 }
                                                 }
                                                 }  
                                                 }
                                                 }
int main()                                         {
cout<<"WELCOME TO TENSE.TELLER"<<endl;
cout<<"THIS PROGRAM WILL TELL YOU WHAT TENSE IS THE SENTENCE THAT YOU TYPE AND ENTER IS WRITTEN IN."<<endl;
cout<<"PLEASE ENTER YOUR SENTENCE: "<<endl;
cout<<AcProgram();
                                                 }



hi guys this is my program which tells the tense of the sentence the user inputs.but when ever i test it ,it prints something weird which is neither in English nor in numbers.Sample input is:
I am a boy.
from this the output should be that the program prints on the screen"its in present indefinite"(without the quotes).

Is This A Good Question/Topic? 0
  • +

Replies To: Tense.Teller(getting a weird error).

#2 jimblumberg  Icon User is online

  • member icon

Reputation: 3055
  • View blog
  • Posts: 9,292
  • Joined: 25-December 09

Re: Tense.Teller(getting a weird error).

Posted 14 September 2012 - 11:51 AM

Please stop opening a new topic for the same question. You already have a topic open for this question see this link.

Duplicate topic closed.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1