science C++ programing

could you please help me with this program even with one part please:
Adding two strings (Actually, the correct term is concatenate because unlike adding two number and
getting a new result, we add a second string to the end of the first one and getting a string which is
basically the two string one right after the other).
Example: "Hello" + " World" = "Hello World" (do not add a space, notice it exist on the second string)
also, "U" + 2 = "U2" (for now you may assume that only integers will be added and not floats or doubles).
• Outputting a string to the output.
writing cout << s1 << endl; will result in outputting the string's contents to the screen.
this is easy because there is already an operator<< for char*
• Inputting a string to a MyString object.
writing cin >> s1; will result in s1 contents to contain the inputted string.
this is different than inputting a char* because operator>>(istream&,char*) assumes enough memory is
allocated for the input and it will override existing memory if input is larger than the allocated space.
In order to overcome this problem, define a static array of size MAX_STRING, read the char* input to it,
calculate the input's length, allocate the needed space and copy into the allocated memory.
• Get the length of a string. For a MyString object s1 that contains the string "Hello",
s1.Length() will return an integer representing the s1's length (without the /0).
• Indexing a string – allow your users to change the string in specific locations and retrieve specifics
characters from it.
For example, for s MyString objects s1 that contains the string "Hello",
the statement: char ch = s1[2]; would assign the third character of the string to ch. In this case ch is now
'l'.
Also, the statement: s1[4]=0 will cause s1 to change to "Hell".
so you need to support two functionalities with indexing (read the class and recitation notes)
• Find a character's index in a string. This function will scan the string for the char parameter and will return
the index of the first occurrence in the string. If the character does not appear in the string, return -1.

  1. 👍 0
  2. 👎 0
  3. 👁 30
asked by fady

Respond to this Question

First Name

Your Response

Similar Questions

  1. mathematics word problems

    Club members wrote a program together, with several people working on each of 4 parts. If the first part of the program required 1/3 of the total time, the second part needed 1/2 of the remaining time, the third part took 30

    asked by Epson on August 7, 2014
  2. physics

    A ball of mass m = 500g moves around a vertical axis with an angular speed ù. It is attached to two strings of length: the upper a = 30 cm and the lower b = 40 cm.Both strings are taut and perpendicular to each other. Each of the

    asked by jamie on December 9, 2008
  3. physics

    a 1.29 kg ball is connected by means of two massless strings to a vertical, rotating rod. The strings are tied to the rod and are taut. The tension in the upper string is 38 N. The length of both strings is 1.70m and the distance

    asked by K on November 20, 2011
  4. Physics

    4 kg mass is placed on the smooth horizontal tabke.two light inextansible strings are connected to it and two masse 2kg and 5kg are attached to the free ends of the strings. Find the accelaration of each objects and the tension of

    asked by Anonymous on February 8, 2013
  5. Elective maths

    A particle P of mass 7kg is suspended by two inextensible strings AP,BP of lengths 40cm and 75cm respectively. The ends, AP of the strings are attached to two point at the same level, whose distance apart is 85cm. Find angle APB

    asked by Samuel on October 6, 2015
  6. physics

    Two strings are vibrating at the same frequency of 113 Hz. After the tension in one of the strings is decreased, an observer hears two beats each second when the strings vibrate together. Find the new frequency in the adjusted

    asked by romal on March 25, 2015
  7. physics

    An object of weight 50 N is suspended vertically by two strings. The strings are of the same lenght and the angle between them is 60 degree. Draw a free body diagram of the forces acting on the object. Calculate the tension in the

    asked by waslat on March 15, 2014
  8. statistics

    Part 1) A physical therapists wishes to determine whether an exercise program increases flexibility. He measures the flexibility (in inches) of 12 randomly selected subjects both before and after an intensive eight-week training

    asked by Rob on March 7, 2011
  9. At-Risk children

    Create a plan for identifying potential students for the new at-risk program by completing the following points: These are the questions I have to yse. What part of the at-risk population will the program serve? 2. How will

    asked by sally on November 2, 2008
  10. physics

    Two balls have the same mass of 0.525 kg and identical charges of 13.0 μC. They hang from the ceiling on strings of identical length as shown in the figure. If the angle with respect to the vertical of the strings is 22.0°, what

    asked by onder on October 15, 2011
  11. physics

    Two balls have the same mass of 3.085 kg and identical charges of 21.0 ìC. They hang from the ceiling on strings of identical length as shown in the figure. If the angle with respect to the vertical of the strings is 22.0°, what

    asked by emine on October 14, 2011

More Similar Questions