SOURCE CODE: SIMPLE ARITHMETIC USING ENGLISH WORDS by sirjon
#include<iostream>
using namespace std;
int goAhead1(string tell, string tell1,string tell2)
{
tell="CANNOT ";
tell1="EASILY BE ";
tell2="COMPUTED";
cout<<" "<<tell<<tell1<<tell2<<"\n";
return 0;
}
int goAhead (string Entry, string Entry1, string Entry2)
{
int x=0;
int y=0;
int sum=0;
int set = 0;
int set2= 0;
int difference=0;
string Wsum;
string Wdifference;
string wordedNumbers[16]={"NEGATIVE FIVE","NEGATIVE FOUR","NEGATIVE THREE","NEGATIVE TWO","NEGATIVE ONE","ZERO","ONE","TWO","THREE",
"FOUR", "FIVE","SIX","SEVEN","EIGHT","NINE","TEN"};
string *q;
q=&wordedNumbers[0];
int realNumbers[16]={-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10};
int *p;
p=&realNumbers[0];
for (int i=0; i<16; i++)
{if (*(q+i)==Entry)
{x=*(p+i);}
else {set = 0;}
}
for (int i=0;i<16;i++)
{if (*(q+i)==Entry2)
{y=*(p+i);}
else {set2 = 0;}
}
sum=x+y;
if(sum>=11)
{int proceed;
string tell;
string tell1;
string tell2;
proceed = goAhead1(tell, tell1,tell2);
}
difference=x-y;
if(difference<=-11)
{int proceed;
string tell;
string tell1;
string tell2;
proceed = goAhead1(tell, tell1,tell2);
}
for (int i=0;i<16;i++)
{if (*(p+i)==sum)
{Wsum=*(q+i);}
}
for (int i=0;i<16;i++)
{if (*(p+i)==difference)
{Wdifference=*(q+i);}
}
if(sum==set)
{Wsum="NOT IN MY PROGRAM";}
if(sum==x)
{Wsum="NOT IN MY PROGRAM";}
if(sum==y)
{Wsum="NOT IN MY PROGRAM";}
if (Entry1=="PLUS")
{if(sum<=10)
{cout<<" I KNOW THE ANSWER..."<<"\n";
cout<<" "; cout<<Entry<<" PLUS "<<Entry2<<" IS "<<Wsum<<"\n";}
}
if(sum==set2)
{Wdifference="NOT IN MY PROGRAM";}
if(sum==x)
{Wdifference="NOT IN MY PROGRAM";}
if(sum==y)
{Wdifference="NOT IN MY PROGRAM";}
if (Entry1=="MINUS")
{if(difference>=-5)
{cout<<" I KNOW THE ANSWER..."<<"\n";
cout<<" "; cout<<Entry<<" MINUS "<<Entry2<<" IS "<<Wdifference<<"\n";}
}
return 0;
}
int main ()
{
int proceed;
string Word;
string Word1;
string Word2;
string stopper;
string stopper1;
string stopper2;
string stopper3;
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<" DO SIMPLE ADDITION AND SUBTRACTION IN ENGLISH WORDS \n";
cout<<"\n";
cout<<" Enter numbers from 'ONE' to 'FIVE' ONLY! (in common English words)\n";
cout<<"\n";
cout<<" DIRECTION:\n";
cout<<" Use the word 'PLUS' to ADD TWO NUMBERS...\n";
cout<<" Use 'MINUS', to SUBTRACT...\n";
cout<<"\n";
cout<<" Follow this format: ONE PLUS ONE then 'HIT' the ENTER key"<<"\n";
cout<<"\n";
cout<<" **Important: ALL IN UPPER-CASE LETTERS (Tip: HIT the Caps Lock in your keyboard) \n";
cout<<"\n";
cout<<" REMINDER: Type 'STOP ASKING ME' if you no longer want to continue" <<"\n";
cout<<" (TAKE NOTE: We can still add two numbers greater than FIVE, as long as the sum is not"<<"\n";
cout<<" over 10 or can subtract, with difference not less then NEGATIVE FIVE)"<<"\n";
cout<<"\n";
cout<<"\n";
while(Word!="STOP",Word1!="ASKING",Word2!="ME")
{
cout<<"\n";
cout<<" ASK A QUESTION: ";
cin>>Word>>Word1>>Word2;
if(Word=="STOP",Word1=="ASKING",Word2=="ME")
{ stopper = " 'THANK ";
stopper1= "YOU ";
stopper2= "FOR ";
stopper3= "PARTICIPATING!'";}
else {proceed= goAhead(Word,Word1,Word2);}
}
cout<<"\n";
cout<<" "<<stopper<<stopper1<<stopper2<<stopper3;
return 0;
}
Comments
Post a Comment