Directions | Computer Science homework help

  

Directions:

Write C++ programs that use proper style and documentation

The purpose of this assignment is to assess if you can create a program that uses strings.

The file must be called stringProg.cpp

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.

Provide documentation throughout the program. Ensure you include ALL files required to make your program compile and run. I would like to see your .cpp file and the .exe file that is inside your debug directory. 

Only for LogicPro, C++ program. Please check the link for the attached direction document.
 

http://wikisend.com/download/175314/Week 1 Homework Directions.doc

Submitted: 3 days and 16 hours ago.

Category: Homework

Status: CLOSED

Optional Information

Optional Information:
Subject: C++

Posted by LogicPro 3 days and 16 hours ago.

Response From Expert

Hi,
Welcome back and Thank you for asking me.
Hope you are doing well.
What is the deadline for this?

3 days and 15 hours ago.

Customer Reply

I’m doing good, hope same for you.

 
 

Deadline is Sunday 1/20/2013 @ 9:00PM CST

Posted by LogicPro 3 days and 15 hours ago.

Response From Expert

Thank you.
I will provide you answer ASAP.

Posted by LogicPro 3 days and 12 hours ago.

Expert’s Answer

Download answer from here stringProg.cpp
 

You can ask me again using “For LogicPro only” at the start of your questions like you did to get instant answers.
It will ensure that question is for me.
Please bookmark my profile page:
http://www.justanswer.com/computer/expert-logicpro/
so you can come back and ask me a question anytime.

18 hours ago.

Customer Reply

I’m getting this error when trying to compiling it. Please see below.

 
 

[email protected]$ g++ -o stringProg stringProg.cpp
stringProg.cpp: In function ‘void outputData(std::string)’:
stringProg.cpp:94: error: ‘system’ was not declared in this scope

 
 

Posted by LogicPro 18 hours ago.

Response From Expert

I will check and reply in few hours

17 hours ago.

Customer Reply

 I used a g++ compiler on a Linux OS. If you have another method to compile please let me know.

Posted by LogicPro 15 hours ago.

Response From Expert

I used dev c++

15 hours ago.

Customer Reply

 Ok, did you fix the error in the code?

15 hours ago.

Customer Reply

 I downloaded that too and tested it there. It failed with dev c++. Did you test the code?

Posted by LogicPro 15 hours ago.

Expert’s Answer

Remove the line system(“pause”) from code and then run it.

15 hours ago.

Customer Reply

It displays my name twice! I don’t think that is correct. Can you check?

Posted by LogicPro 15 hours ago.

Response From Expert

let me check.

Accepted Answer