Click here to Skip to main content
15,900,907 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Main Method
1. Declare a string called myString.
2. Use Call-by-reference pass your string to a method called inputData(); (Hint: uses the &)
3. Use Call-by-value and pass your string to a method called outputData(); (Hint: does not use the &)
inputData Method (Receives string)
1. Get input using cin >> into the string variable you received into this method. (I will be entering my full name in the format of: Last, First Middle.
2. Using the string methods mentioned in this weeks lecture, have your program change the string to: First Middle Initial Last.
3. I would like you to break the string you received apart into 3 separate variables: first, last, middle. (Hint: use find() to find the "," and spaces and use substr() to extract the pieces)
4. Use string concatenation to reassemble the string and overwrite the string you received with the new value.
5. You must use each of the following string methods (at least once): substr(), length(), find(), insert(), erase().
6. Notice the "," is missing out of the name.
outputData Method (Receives string)
1. Output the new string to the screen using cout <<.
2. Comments are required, but pseudocode or flowchart are not.
3. All Input/Output should be done using the standard C++ library string class.
4. Include: system("PAUSE"); after your output to pause the screen.
Posted
Comments
Chandrasekharan P 25-Jan-12 6:52am    
Nobody here will write a code for you unless you pay them. Start with the code and get back to the forum when you have a doubt.
Jochen Arndt 25-Jan-12 7:28am    
You should do your homework yourself.

Even if you find somebody here, he can't know about 'the string methods mentioned in this week lecture'.

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is easier than you think.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900