hey guys i had a program using a function to form the plurals of English nouns according to the following rules and it just aint working any help would be great thnx
//File: lab9-part1
//Programmer:Ravi Mandair CPSC 1103 Section 10
//Purpose:To write a program to form plurals of english nouns
//word.remove(index_last, 1);
#include<iostream>
#include <string>
using namespace std;
string ends_in_y_not_o(int, string);
string default_cases(int, int, string);
int main()
{
char ans;
int length, index_last, index_2last;
string word;
cout<<"Hello\n";
do
{
cout<<"Please enter a noun to form its plural form:\n";
cin>>word;
length = word.length();
index_last = length - 1;
index_2last = length - 2;
if ((word[index_last] == 'y') && (word[index_2last] != 'o'))
word = ends_in_y_not_o(index_last, word);
else
word = default_cases(index_last, index_2last, word);
cout<<"The plural form is:\n";
cout<<word;
cout<<"\nAgain? (Y for ""yes"" and N for ""no"")\n";
cin>>ans;
}while (ans == 'y' && ans != 'Y');
cout<<"Written by: Ravi Mandair CPSC 1103 Section 10.\n";
return 0;
}
string ends_y_not_o(int index, string noun)
{
string word;
word = noun.substr(0, index);
word = word + "ies";
return word;
}
string default_cases(int index_1, int index_2, string noun)
{
if ((noun[index_1] == 's') || ((noun[index_1] == 'h') &&
((noun[index_2] == 's')
|| (noun[index_2] == 'c'))))
noun = noun + "es";
else
noun = noun + "s";
return noun;
}