answer.
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]
2 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]2 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
Give a recursive (or non-recursive) algorithm to compute the product of two positive integers, m and n, using only addition and
LiRa [457]

Answer:

Multiply(m,n)

1. Initialize product=0.

2. for i=1 to n

3.      product = product +m.

4. Output product.

Explanation:

Here we take the variable "product" to store the result m×n. And in this algorithm we find m×n by adding m, n times.

6 0
2 years ago
The it department is reporting that a company web server is receiving an abnormally high number of web page requests from differ
Talja [164]
<span>In the scenario in which the IT department is reporting that a company web server is receiving an abnormally high number of web page requests from different locations simultaneously the DDoS security attack is occurring.
</span>DDos stands for Distributed Denial of Service<span> . This </span><span>attack is an attempt to make an online service unavailable by overwhelming it with traffic from multiple sources.</span>
8 0
2 years ago
Sea level is the average level of the sea between high and low tide. It is used as a reference point for measuring elevation, or
SSSSS [86.1K]

Answer:

-8 and 735

Explanation:

Since the sea is a body of water (fluid) it takes the same properties as a fluid does which means filling an area and finding a leveled point. This is why we use the sea as a starting elevation point for Earth's land and it is given a numerical value of 0. Since it starts at 0 any land above Sea Level is in the positives while land below Sea Level is in the negatives. Therefore Since New Orleans is 8 feet below sea level its numerical value elevation is -8. The highest point in Chicago is 735 feet above sea level which makes its numerical value 735

6 0
2 years ago
Read 2 more answers
Consider the following method, which is intended to return an array of integers that contains the elements of the parameter arr
Gennadij [26K]

Code:

public static int[] reverse(int [] arr){

Int [] newArr = new int[arr.length];

for (int k = 0; k<arr.length;k++){

/*Missing statement */

}

return newArr;

Answer:

Replace the comment with:

newArr[k] = arr[arr.length-k];

Explanation:

Required

Complete the code

In the given code:

The first line of the given code defines the method

public static int[] reverse(int [] arr){

The next line declares array newArr withe same length as array arr

Int [] newArr = new int[arr.length];

The next line iterates through the elements of array arr

for (int k = 0; k<arr.length;k++){

The /* Missing statement */ is then replaced with:

newArr[k] = arr[arr.length-k];

The above statement gets the elements of array arr in reversed order.

This is so because, as the iteration iterates through array arr in ascending order, arr.length-k gets the element in reversed order

6 0
2 years ago
Sharon reads two different articles about avocados. The first article, in a weight loss magazine, claims that avocados are unhea
padilas [110]
The first and third.
3 0
2 years ago
Read 2 more answers
Other questions:
  • In three to five sentences, describe whether or not files should be deleted from your computer.
    13·2 answers
  • Which technology had the same effect in the 1920s as the internet did in the 2000s? the widespread effect of technology 1920s 20
    8·1 answer
  • In computing, a(n) _____ is an attack on an information system that takes advantage of a particular system vulnerability. Select
    5·1 answer
  • An analyst receives an alert from the SIEM showing an IP address that does not belong to the assigned network can be seen sendin
    9·1 answer
  • Use the image below to answer this question.
    14·1 answer
  • Write a program that replaces words in a sentence. The input begins with word replacement pairs (original and replacement). The
    11·1 answer
  • PC’s &amp; More has shifted to sales and service of laptops and PCs, where it has the potential to triple the number of its cust
    14·1 answer
  • Write multiple if statements: If carYear is before 1968, print "Probably has few safety features." (without quotes). If after 19
    6·1 answer
  • Create a class called Date that includes three pieces of information as instance variables—a month (type int), a day (type int),
    11·1 answer
  • Write measurable performance objectives.Suppose that a trainer has identified as a generalgoal for a training module,"Able to fo
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!