hi guys , im designing a c++ code for an assignment and im badly stuck.i have to create a programme word checker to change plurals to nouns. i have it completed but have to store it as statistics. so when the user selects the VIEW button at the end of any game, he or she can view the nouns and plurals they have entered up to then.
please help me out. here is my code.:::
#include<iostream>//include in/out stream library
#include <string> //include standard string library
using namespace std;//using the naming convention std
int main ()
{
int replay;
char option [2];
cout<<"welcome to spellcheck,below are your main options, please select one, thank you"<<endl;
cout<<"Menu: \n\n";
cout<<"1. Start\n\n";
cout<<"2. View\n\n";
cout<<"3. Close\n\n";
cin>> option;
if(option[0] == '1')
{
cin.get();
system("CLS");
string singWord, pluralWord;
int n;
char lastChar, secLastChar;
start:
cout<<"Please enter a word: "<<endl;
while (true)
{
cin>>singWord;
n=singWord.length();
lastChar=singWord[n-1];
secLastChar=singWord[n-2];
if (singWord == "deer"){
cout<<"The word is a special word. \n";
cout<<"The plural of "<<singWord <<" is "<<singWord<<endl;
}
else if (singWord =="moose"){
cout<<"The word is a special word";
cout<<"The plural of "<< singWord <<" is "<<singWord<<endl;
}
else if (singWord =="sheep"){
cout<<"The word is a special word";
cout<<"The plural of "<< singWord <<" is "<<singWord<<endl;
}
else if (lastChar=='y'){
pluralWord=singWord.substr(0,n-1)+"ies";
cout<<"The plural word is: "<<pluralWord<<endl;
}
else if (lastChar=='o'||lastChar=='s'||lastChar=='x'){
pluralWord=singWord+"es";
cout<<"The plural word is: "<<pluralWord<<endl;
}
else if (lastChar=='h'&& lastChar=='c'){
pluralWord=singWord+"es";
cout<<"The plural word is: "<<pluralWord<<endl;
}
else if (lastChar== 'f'){
pluralWord=singWord.substr(0,n-1)+"ves";
cout<<"The plural word is: "<<pluralWord<<endl;
}
else if (lastChar=='e'&&secLastChar=='f'){
pluralWord=singWord.substr(0,n-2)+"ves";
cout<<"The plural word is: "<<pluralWord<<endl;
}
else{
pluralWord=singWord+"s";
cout<<"The plural word is: "<<pluralWord<<endl;
}
cout<<"do you want to play again? press 1 for yes and 2 for no"<<endl;
cin>>replay;
cout<<"you choose "<<replay<<" .thank you"<<endl;
while (replay <=0)//declare a while loop for negatives
{//start of line verification
cout<<"YOU HAVE ENTERED THE INVALID NUMBER OF "<<replay<<" . PLEASE TRY AGAIN!! "<<endl;//show user their invalid entry
cout<< "PRESS 1 TO RESTART THE GAME AND 2 TO FINISH THE GAME, THANK YOU"<<endl;//give the user the options again
cin>>replay;//user input
}//end of line verification
if (replay >=3 )// if the case where entry greater than 3
{//start of line verification
cout<<"YOU HAVE ENTERED THE INVALID NUMBER OF "<<replay<<" . PLEASE TRY AGAIN!! "<<endl;//show user their invalid entry
cout<< "PRESS 1 TO RESTART THE GAME AND 2 TO FINISH THE GAME, THANK YOU"<<endl;//give the user the options again
cin>>replay;//please enter input
}//end of line verification
if (replay ==2) return 0;//if input is 2,then quit the game
if (replay ==1) goto start;//if input is 1 then restart the game and send programme back to start
}
cin>>option;
}else if (option[0] == '2'){
system("CLS");
cout<<"Game Stats!\n";
}else if (option[0] == '3'){
return 0;
}
system("pause"); //pause the system so the judges can see the result before ending
return 0;
}//end of line verification