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
Jack and Diane are creating each ClassID following this pattern: first two letters of ClassName (one uppercase, one lowercase),
Norma-Jean [14]

Answer:

i dont know 123 IdK

Explanation:

6 0
4 years ago
Code is the code or instructions used to create a Web page or<br> program.
Paha777 [63]
Answer:
HTML
Explanation:

5 0
3 years ago
When an employee is told that his job will be outsourced within a year, he knows that his job will become unnecessary
Anvisha [2.4K]
False!! Hope this helps
8 0
3 years ago
What is the output, if userVal is 5? int x; x = 100; if (userVal != 0) { int tmpVal; tmpVal = x / userVal; System.out.print(tmpV
spayn [35]

Answer:

The output is 20

Explanation:

This line divides the value of x by userVal

tmpVal = x / userVal;

i.e.

tmpVal = 100/5

tmpVal = 20

This line then prints the value of tmpVal

System.out.print(tmpVal);

i.e 20

Hence, The output is 20

4 0
3 years ago
. A search engine is a way to
Sindrei [870]
<span>Option A, the search engine is the way to get information on the internet through a web browser, installed on an operating system of a computer. It is software that gathers all the information and stores it to accelerate the search for the users by entering the data of the desired information.</span>
8 0
4 years ago
Read 2 more answers
Other questions:
  • A(n ____________ is considered a named collection of bytes having persistent or lasting storage.
    10·1 answer
  • Write a program whose inputs are three integers, and whose output is the smallest of the three values.
    6·1 answer
  • In linux, you are restricted to using only one type of filesystem on a system.
    15·1 answer
  • The analysts at Techno Info Systems are considering the four-model approach to system development for a new client. If they make
    12·1 answer
  • Write a Python program that creates a dictionary containing course numbers and the room numbers of the rooms where the course me
    7·1 answer
  • What do you call when a hacker users multiple guest computers to crack a password?
    11·1 answer
  • Define a member function PrintAll() for class PetData that prints output as follows. Hint: Make use of the base class' PrintAll(
    8·1 answer
  • Which is the best book for digital electronics?
    5·1 answer
  • Answer the following questions based on your readings from Module 1. Describe a time when you or someone you observed showed a p
    9·1 answer
  • What is the difference between a crosstab query and a subquery?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!