1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alex73 [517]
3 years ago
9

Create a program that includes a function called toUpperCamelCase that takes a string (consisting of lowercase words and spaces)

and returns the string with all spaces removed. Moreover, the first letter of each word is to be forced to its corresponding uppercase. For example, given "hello world" as the input, the function should return "HelloWorld". The main function should prompt the user to input a string until the user types "Q". For each string input call the function with the string and display the result. (Hint: You may need to use the toupper function defined in the header file.)
Computers and Technology
1 answer:
astraxan [27]3 years ago
8 0

Answer:

#include<iostream>

using namespace std;

//method to remove the spaces and convert the first character of each word to uppercase

string

toUpperCameICase (string str)

{

string result;

int i, j;

//loop will continue till end

for (i = 0, j = 0; str[i] != '\0'; i++)

{

 if (i == 0)       //condition to convert the first character into uppercase

  {

  if (str[i] >= 'a' && str[i] <= 'z')   //condition for lowercase

  str[i] = str[i] - 32;   //convert to uppercase

  }

if (str[i] == ' ')   //condition for space

  if (str[i + 1] >= 'a' && str[i + 1] <= 'z')   //condition to check whether the character after space is lowercase or not

  str[i + 1] = str[i + 1] - 32;   //convert into uppercase

if (str[i] != ' ')   //condition for non sppace character

  {

  result = result + str[i];   //append the non space character into string

  }

}

//return the string

return (result);

}

//driver program

int main ()

{

string str;

char ch;

//infinite loop

while (1)

{

fflush (stdin);

//cout<< endl;

getline (cin, str);   //read the string

//print the result

//cout<< endl << "Q";

// cin >> ch; //ask user to continue or not

ch = str[0];

if (ch == 'q' || ch == 'Q')   //is user will enter Q then terminatethe loop

  break;

cout << toUpperCameICase (str);

cout << endl;

}

return 0;

}

You might be interested in
What permanent magnets of a motor are replaced with more powerful ones, what effect do you think this would have on motor rotati
Marat540 [252]
When permanent magnets of a motor are replaced with more powerful ones, the motor rotation will increase. This is because there is more electricity being generated.
7 0
3 years ago
Read 2 more answers
"So far this month you have achieved $100.00 in sales, which is 50% of your total monthly goal. With only 5 more workdays this m
Rus_ich [418]

Answer:

$20 per day for next 5 working days.

Explanation:

if 50% is $100.00 another $100 need to achieve in 5 days.

100/5=20

3 0
3 years ago
Read 2 more answers
If it malfunctions and I can throw it, then it's a hardware problem; if I have to yell at it because there is nothing to pick up
kobusy [5.1K]
Software problem.
Assuming "Software" is one of the available answers.

3 0
3 years ago
Read 2 more answers
A heart murmur is caused by incorrect operation of ________?​
Levart [38]

Answer:

the valves

Explanation:

science explains your questions answer. also did you know that the queen was an engineer in WWII? you probably did but you need 20 characters to submit an answere trust me it is the valves.

6 0
3 years ago
50-75 words about what motivates you in academic life and are these motivators different from what motivates you in your persona
drek231 [11]

<u>Answer:</u>

<em>My teachers & My parents are the main reason to get through academics well. </em>

Though the reason might be common to most of the people, <em>the situation might be unique and the way the advice's are comprehended and the process of intake and the actions would be unique to each person.</em>

How a mother gives medicine to a child along with sugar, in a similar way my <em>parents and teachers gave me advice which made me to stand at this top-level.</em>

6 0
3 years ago
Other questions:
  • Please write a Java program.
    8·1 answer
  • Often used in connection with a business
    6·1 answer
  • What is the configuration of a multimedia computer​
    10·1 answer
  • The IntList class contains code for an integer list class. Study it; notice that the only things you can do are: create a list o
    7·1 answer
  • 16 to 19 year old drivers are how many more times likely to crash? 1.7,2.7,0.7 ,3.7
    12·2 answers
  • Identify a characteristic of electronic meeting systems.
    10·1 answer
  • The analogy of a computer system is often used to illustrate the different parts of memory. The keyboard is where we encode new
    8·1 answer
  • In case of a suspected data breach, what course of action should a chief information security officer (CISO) take
    9·1 answer
  • Your first submission for the CIS 210 Course Project should include the following functionality: - Requests the user to input hi
    13·1 answer
  • Please select the word from the list that best fits the definition Asking for review material for a test
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!