Ok, so i have to write 2 codes base on the following questions: 1) Write a program that takes nouns and forms their plurals on the basis of these rules: a. If the noun ends in "y," remove the "y" and add "ies." b. If the noun ends in "s," "ch," or "sh," add "es" c. In all other cases, just add "s." So, i know i have to use if/else statement and strlen to get what I want to do. But I don't understand how to initially set it up. Ok, maybe I don't know what it looks like. So, maybe someone can give me an example of the string manipulation? I really hate strings. 2) Define a structure type elemnt_t to represent one element from the periodic table of elements. Compounds should include the atomic number(integer); the name, chemical symbol, and class (strings); a numeric field for the atomic weight; and seven-element array of integers for the number of electrons in each shell. The following are the components of an element_t structure for sodium. 11 Sodium Na alkali_metal 22.9898 2 8 1 0 0 0 0 Define and test I/O functions scan_element and print element. Ok, i understand this is like an 80 line code, so i know no one will write me the whole code and I do not condemn them to do that. Basically, my question is, how do I get the information in? Thats my only real question. I'm sure I can figure out the code once I understand how to get the information in and then the only thing that I am really confused on is what does it mean to "Define and test I/O functions scan_element and print element?" So, any help is appreciated.
Well it may be a little late but, the code seems fun to write. Here's an example written in C++ and compiled with gcc. (this code should also work with visual studio ) To compile the code in unix 1- save the file (in my case I named it Pluriel.cpp) 2- write this commande line in your folder where the file is (if using unix ) gcc Pluriel.cpp -lstdc++ -o Pluriel 3- type in the command line ./Pluriel Here's the code Code (Text): #include <iostream> #include <string.h> using namespace std; #define END_WITH_Y 1 #define END_WITH_S_SH_CH 2 #define END_WITH_NOTHING_SPECIAL 3 int checkKindOfNoun(string tmp) { string subStringOneChar = tmp.substr( tmp.length() -1 , 1 ); if( subStringOneChar == "y" ) { return END_WITH_Y ; } string subStringTwoChar = tmp.substr( tmp.length() -2 , 2 ); if(subStringTwoChar == "sh" || subStringTwoChar == "ch" || subStringOneChar == "s" ) { return END_WITH_S_SH_CH; } else { return END_WITH_NOTHING_SPECIAL; } } string addPlurialOne(string tmp) { string subString =tmp.substr( 0 , tmp.length() -1 ); subString = subString + "ies"; return subString ; } string addPlurialTwo(string tmp) { tmp = tmp +"es"; return tmp ; } string addPlurialThree(string tmp) { tmp =tmp + "s"; return tmp ; } int main( void ) { cout << "Enter your noun, we will changes it to plurial !" << endl; string noun = ""; cin >> noun ; int typeOfNoun = checkKindOfNoun(noun); //cout << typeOfNoun ; switch(typeOfNoun) { case END_WITH_Y : cout << addPlurialOne(noun)<<endl; break; case END_WITH_S_SH_CH : cout << addPlurialTwo(noun)<<endl; break; case END_WITH_NOTHING_SPECIAL : cout << addPlurialThree(noun)<<endl; break; } return 0; }