Write a simple program using string operations to create three new strings from a given string....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a simple program using string operations to create three new strings from a given string. (a) The newly created string should swap the first and last characters and keep all the other characters as is. The program should ensure that only the first character is in the uppercase if it is an alphabet. For example, if the input is "Lineman" the output should be "ninemal". (b) The newly created string should reverse the order of only the characters in the middle leaving the first and last characters as is. For example, if the input is "Lineman" the output should be "Lamenin". (c) The newly created string should reverse the second half of the string leaving the first half as is. For strings with odd number of characters, include the middle character in the econd half. For example, if the input is "Lineman" the output should be "Linname". Write a simple program using string operations to create three new strings from a given string. (a) The newly created string should swap the first and last characters and keep all the other characters as is. The program should ensure that only the first character is in the uppercase if it is an alphabet. For example, if the input is "Lineman" the output should be "ninemal". (b) The newly created string should reverse the order of only the characters in the middle leaving the first and last characters as is. For example, if the input is "Lineman" the output should be "Lamenin". (c) The newly created string should reverse the second half of the string leaving the first half as is. For strings with odd number of characters, include the middle character in the econd half. For example, if the input is "Lineman" the output should be "Linname".
Expert Answer:
Answer rating: 100% (QA)
23 2 mainpy 1 def modifystringinputstr a Swap the first and last characters keeping other char... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In Python 1) Write a program that asks the user to enter a string. The program should then print the following: (a) The total number of characters in the string (b) The string repeated 10 times (c)...
-
Find the lengths of the curves. The curve r = a sin 2 (/2), 0 , a > 0
-
Why must entrepreneur concentrate on effective cash flow management?
-
In Exercises evaluate the definite integral. Use a graphing utility to verify your result. fo (2 - t) t dt
-
A single stage reciprocating compressor is required to compress \(1 \mathrm{~kg}\) of air from 1 bar to 8 bars. The initial temperature of the air is \(20^{\circ} \mathrm{C}\). Calculate work for...
-
Is an initial public offering an example of a primary or a secondary market transaction?
-
A 20N force acts perpendicular to the door 0.8m wide at its edge. Find moment at hinges. Also find moment at hinges if 20N force acts at 60 with the plane of door. i) 20N force acting perpendicular...
-
Under what circumstances should a systems analyst recommend an agile methodology over structured development or object-oriented analysis?
-
Whats the role of martial arts in Asian representation?
-
Discuss different inputs in the individual job levels of the diagnostic model?
-
Simplify. 2 4y +48y +144 +4y-12 2 y
-
Q13: Spiral spring Motion: A mass is hanged on the end of vertical spring which is shown in figure. If the spring is stretched 12 cm and the mass become to rest, if the energy stored in the spring is...
-
The volume of a monatomic ideal gas doubles in an isothermal expansion. By what factor does its pressure change? As an ideal gas expands at constant pressure from a volume of 0.74 m to a volume of...
-
discuss different roles and levels of responsibility of employees
-
An economy is represented by the following three equations: The Beta in Okuns law is 0.5 The alpha in the Philips curve is 1. The natural rate of growth g n is 3%. The Natural Unemployment rate U n...
-
Let (x) = x 2 - 9, g(x) = 2x, and h(x) = x - 3. Find each of the following. (((--) 2
-
Whats wrong, if anything, with the following code? class Kitchen { private: double kit_sq_ft; public: Kitchen() {kit_sq_ft = 0.0; } virtual double area() const { return kit_sq_ft * kit_sq_ft; } };...
-
What is the relationship between an object and a class?
-
Redo Listing 5.4 using a type array object instead of a built-in array and type long double instead of long long. Find the value of 100! Here is the output from the program in Listing 5.4: 0! = 1 1!...
-
You lift a book at a constant speed. Which statement is true about the work W done by your hand and the change in the book's gravitational potential energy U g ? A. W> AU>0 B. W < AU <0 C. W=AU>0 D....
-
At a point where the electric potential is 400 V, a positive charge is moving to the left. As the charge continues to move, it slows down, stops, and then begins to move back to the right. Using what...
-
A positively charged particle moves from point I to point 2. As it does, its electric potential energy? A. Increases. B. Decreases. C. Stays the same. 102
Study smarter with the SolutionInn App