1

Trouble with formatting titles :( Your friend is in charge of recording titles of books in...

Question

Trouble with formatting titles :( Your friend is in charge of recording titles of books in...

trouble with formatting titles :( Your friend is in charge of recording titles of books in the library they work in. Since th
stringToTitleCase (hello) should return Hello stringToTitleCase (look! im a title!) should return Look! Im A Title!
trouble with formatting titles :( Your friend is in charge of recording titles of books in the library they work in. Since they know you're in EECS 183, they've asked you to write a function that turns a lowercase string into Title Case format. This way, they can use the function to correctly format the titles without having to worry about capitalizing anything themselves. The function you will implement is stringToTitleCase, which takes a lowercase string str as input and returns a string that is identical to str except each word begins with an uppercase letter. While implementing this function, feel free to use our predefined toupper() function. A description of its functionality can be found below: Syntax; char toupper(char ch); Parameter: This method takes a mandatory parameter ch which is the character to be converted to uppercase. Return Value: This function returns the uppercase character corresponding to the ch. Example Usage: char lowercaseChar 'e'; cout << toupper(lowercaseChar); - This line prints E
stringToTitleCase ("hello") should return "Hello" stringToTitleCase ("look! i'm a title!") should return "Look! I'm A Title!" Write your implementation of stringToTitleCase in the box below. There is a repl.it with starter code that the Scribe can share at https://repl.it/QJohnKloosterman/183Lab5titleCase: * REQUIRES: str must contain all lowercase letters + MODIFIES: nothing * EFFECTS: Returns a string identical to str formatted in Title Case * string stringToTitleCase(string str) { // Implement this function return " "; } int main() { cout << stringToTitleCase("hello") << endl; cout << stringToTitleCase("look! i'm a title!") << endl; }

Answers

Program:

#include <iostream>
using namespace std;

/**
* REQUIRES: str must contain all lowercase letters
* MODIFIES: nothing
* EFFECTS: Returns a string identical to str formatted in
* Title Case
*/
string stringToTitleCase(string str) {
// Implement this function
string tmp = str;
tmp[0] = toupper(tmp[0]);
for(int i=1; i<tmp.size(); i++)
{
if(tmp[i-1]==' ' && tmp[i]!=' ')
tmp[i] = toupper(tmp[i]);
}
return tmp;
}

int main() {
cout << stringToTitleCase("hello") << endl;
cout << stringToTitleCase("look! i'm a title!") << endl;
}

Output:

Hello Look! Im A Title!

Solving your question and helping you to well understand it is my focus. So if you face any difficulties regarding this please let me know through the comments. I will try my best to assist you. However if you are satisfied with the answer please don't forget to give your feedback. Your feedback is very precious to us, so don't give negative feedback without showing proper reason.
Always avoid copying from existing answers to avoid plagiarism.
Thank you.


Similar Solved Questions

1 answers
Rewrite the following statements to emphasize the positive (e.g. don't panic = negative; stay calm =...
Rewrite the following statements to emphasize the positive (e.g. don't panic = negative; stay calm = positive). 1. An unsecured loan cannot be considered an asset. 2. Contains 95 percent artificial juice. 3. Deemphasize the negative. 4. Don't forget to include your account number. 5. An expe...
1 answers
Wingate Company, a wholesale distributor of electronic equipment, has been experiencing losses for some time, as...
Wingate Company, a wholesale distributor of electronic equipment, has been experiencing losses for some time, as shown by its most recent monthly contribution format income statement Sales Variable expenses Contribution margin Fixed expenses Net operating income (loss) $1,623,000 691,960 931,040 1,0...
1 answers
5. Propose mechanisms for the following reactions (20 points) 1. CH3MgBr OCH CH2HO + CH CH...
5. Propose mechanisms for the following reactions (20 points) 1. CH3MgBr OCH CH2HO + CH CH OH...
1 answers
Consider u(x_{1},x_{2})=x_{1}^{0.5}x_{2}^{0.5},I=300,p_{1}=25,p_{2}=1. If p_{1}decreases from $25 to $9, what is the equivalent variation? Enter a number...
Consider u(x_{1},x_{2})=x_{1}^{0.5}x_{2}^{0.5},I=300,p_{1}=25,p_{2}=1. If p_{1}decreases from $25 to $9, what is the equivalent variation? Enter a number only, round to two decimals. If money needs to be taken away from the consumer include a negative sign. 8.3 Homework Unanswered 0.5 0.5 Consider u...
1 answers
Q's 1-3. Regarding the Raphael and Bryant article, how does the US' approach or focus to...
Q's 1-3. Regarding the Raphael and Bryant article, how does the US' approach or focus to public health differ from: 1. Canada (1 sentence maximum) 2. Sweden (1 sentence maximum) 3. United Kingdom (1 sentence maximum)...
1 answers
A 58 yr. old female school teacher with heart disease and a recent heart attack 6...
A 58 yr. old female school teacher with heart disease and a recent heart attack 6 months ago presents to ER with a complain of heart palpitation, chest discomfort and SOB. She appears anxious and asks repeatedly “Am I having another heart attack?!” Denies any triggers to her symptoms and...
1 answers
I need assistance with the (a) Please show details An engineer wants to determine how the...
I need assistance with the (a) Please show details An engineer wants to determine how the weight of a gas-powered car, x, affects gas mileage, y. The accompanying data represent the weights of various domestic cars and their miles per gallon in the city for the most recent model year. Complete parts...
1 answers
Draw all major resonance structures of the conjugate base of acetophenone. The most acidic hydrogen atom...
Draw all major resonance structures of the conjugate base of acetophenone. The most acidic hydrogen atom in acetophenone is drawn in red. Interactive 3D display mode Draw the molecule on the canvas by choosing buttons from the Tools (for bonds), Atoms, and Advanced Template toolbars, including charg...
1 answers
1. Rank the following in order of strongest intermolecular force to weakest intermolecul force and name...
1. Rank the following in order of strongest intermolecular force to weakest intermolecul force and name the type of intermolecular force for each. (20 points) CH_Ou1 C.H:0 | | Mnso HO | | | F2 CH HOHO | | NaCI | Diamond C2H24 | |...
1 answers
X You received no credit for this question in the previous attempt. Problem 7-2 Scenario Analysis...
X You received no credit for this question in the previous attempt. Problem 7-2 Scenario Analysis We are evaluating a project that costs $800,000, has a life of 8 years, and has no salvage value. Assume that depreciation is straight-line to zero over the life of the project. Sales are projected at 6...
1 answers
The slide generator in the figure below is in a uniform magnetic field of magnitude 0.0500...
The slide generator in the figure below is in a uniform magnetic field of magnitude 0.0500 T. The bar of length 0.385 m is pulled at a constant speed of 0.500 m/s. The U-shaped conductor and the bar have a resistivity of 2.75 times 10^-8 Ohm middot m and a cross-sectional area of 8.50 times 10^-4 m^...
1 answers
How do you find sin2x if sinx = -3/5 and x is in quadrant 3?
How do you find sin2x if sinx = -3/5 and x is in quadrant 3?...
1 answers
Please do not answer if you are not an expert. You will not like the review if you guess. Please ...
Please do not answer if you are not an expert. You will not like the review if you guess. Please explain with detail In three sentences, describe how colloids are stabilised by ionic surfactants. Be as concise as possible while conveying maximal information ParagraphFont familyFont sizeB I US A Pat...
1 answers
CtIUIN1S 01& and E? 2. Using momentum and force principles, explain why an air bag reduces...
CtIUIN1S 01& and E? 2. Using momentum and force principles, explain why an air bag reduces injury in an automobile collision....
1 answers
C# programming 50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (Strin...
C# programming 50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (String) edition ( int) published year (int) Constructor that takes all of the above variables as input par...
1 answers
CHEM 104 Homework 6 2. (15 points): Chapter 18.1, 4.4-5 A chemist is testing the properties...
CHEM 104 Homework 6 2. (15 points): Chapter 18.1, 4.4-5 A chemist is testing the properties of a newly-discovered pair of acids, A1 and A2. She determines them both to be monoprotic and performs several experiments to compare their acid strength: • • Experiment 1: Adding a few drops of bro...
1 answers
Question 1 chapter 13 Handout Assignment
During its first year of operations, Millwoods Enterprises Inc. had the following transactions related to its common shares: Jan 5 - Issued 5,000 common shares to Michelle Vogel for $ 1 each.Mar 15 - Issued 10,000 common shares in exchange for equipment transferred from Vogel. The equi...
1 answers
At a point in a horizontal pipeline, the pressure of the water flowing at a velocity...
At a point in a horizontal pipeline, the pressure of the water flowing at a velocity of 4.6 m/s is 117.3 kPaa; at another point close by, where the pipe has a smaller section, the pressure is 110.4kPaa. a.) Neglecting losses, find the velocity of the flow at the point. b.) If the head loss is .20m, ...

-- 0.055316--