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;
}

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

I don't see any rules here, just code that you claim doesn't work. And if it doesn't work, we can't really use it to understand the rules, can we?

You need to tell us what the problem is, don't make us guess. What is the program doing? What should it do instead?

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.