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
elena-s [515]
3 years ago
14

Write a method that accepts a String object as an argument and returns a copy of the string with the first character of each sen

tence capitalized. For instance, if the argument is "hello. my name is Joe. what is your name?" the method should return the string "Hello. My name is Joe. What is your name?" Demonstrate the method in a program that asks the user to input a string and then passes it to the method. The modified string should be displayed on the screen.
Computers and Technology
1 answer:
emmainna [20.7K]3 years ago
7 0

Answer:

The programming language is not stated; However, the program written in C++ is as follows: (See Attachment)

#include<iostream>

using namespace std;

string capt(string result)

{

result[0] = toupper(result[0]);

for(int i =0;i<result.length();i++){

 if(result[i]=='.' || result[i]=='?' ||result[i]=='!')  {

 if(result[i+1]==' ') {

  result[i+2] = toupper(result[i+2]);

 }

 if(result[i+2]==' ')  {

  result[i+3] = toupper(result[i+3]);

 }

 } }

return result;

}

int main(){

string sentence;

getline(cin,sentence);

cout<<capt(sentence);

return 0;

}

Explanation:

<em>The method to capitalize first letters of string starts here</em>

string capt(string result){

<em>This line capitalizes the first letter of the sentence</em>

result[0] = toupper(result[0]);

<em>This iteration iterates through each letter of the input sentence</em>

for(int i =0;i<result.length();i++){

This checks if the current character is a period (.), a question mark (?) or an exclamation mark (!)

if(result[i]=='.' || result[i]=='?' ||result[i]=='!')  {

 if(result[i+1]==' '){  ->This condition checks if the sentence is single spaced

  result[i+2] = toupper(result[i+2]);

-> If both conditions are satisfied, a sentence is detected and the first letter is capitalized

 }

 if(result[i+2]==' '){ ->This condition checks if the sentence is double spaced

  result[i+3] = toupper(result[i+3]);

-> If both conditions are satisfied, a sentence is detected and the first letter is capitalized

 }

}

}  <em>The iteration ends here</em>

return result;  ->The new string is returned here.

}

The main method starts here

int main(){

This declares a string variable named sentence

string sentence;

This gets the user input

getline(cin,sentence);

This passes the input string to the method defined above

cout<<capt(sentence);

return 0;

}

Download cpp
You might be interested in
Contemporary operation of networking technology is possible only through the usage of open-use technology and layering approache
eimsori [14]

Answer: TRUE

Explanation: Networking technology is the term used to describe the entire processes through which computer or mobile systems are linked up either through optic fibers,wireless systems in order to enhance effective communication across networks or regions.

OSI (open system interconnection), the earliest models partitions into seven layers and the OSI is known as model that creates partitioning a communication system classing them into abstraction layers.

8 0
3 years ago
A growing number of large organizations have built internal Web sites that provide opportunities for online social networking am
Flauer [41]

Answer:

True

Explanation:

The ideology of building internal web sites  for online social networking among employees is aimed towards productivity.

<em>For example, when an employee is finding a specific job difficult and is connected with someone on the social websites created by the organization, the employee will get help in no time to ensure that the organization achieve maximum productivity.</em>

It will constantly keep each employee informed on the organizations policies, goals and achievements.

However, there are shortcomings of online social networking in the workplace:

  1. If not properly managed, It might become addictive and will lead to low employee productivity.
  2. Great intellectual minds might be exposed to negative influences from within the organisation

8 0
3 years ago
Match the context details with the pattern that applies.
tia_tia [17]

Answer:

1. - Observer

2. - iterator

3. - strategy

4. - composite

5. - decorator

Explanation:

An object contains other objects (elements) and must give access to them for clients, without exposing its internal structure. This is an observation.

The subject-object can generate events as an iterable (iterator) and could use different strategic algorithms to achieve a task. Class objects can be used to aggregate other class objects.

In python, the decorator function mimics the outer function of a nested function, but still maintains the functionality of the second function

6 0
2 years ago
A user has a network device that streams media to the LAN. The device is visible on the network. All PCs on the LAN can ping the
trasher [3.6K]

Answer: A. Multicast

Explanation:

Here we are given a situation where it is necessary for the device to stream media to all the PCs connected across the LAN. But as the they are unable to stream the media then it is a problem in the multicast TCP/Ip technology.

Multicasting enables to transfer information or messages from one to many or many to many. Here as a single device is responsible for streaming the content to other PCs across the LAN, therefore it is necessary that multicast has been properly implemented.

Option B is incorrect as it is not a scenario of broadcast as in broadcasting all the receivers must get the streaming however here if a PC does not want to receive the media stream it cannot receive for which multicasting is required.

Option C is incorrect as here we are not talking of one to one communication.

Option D is incorrect as here we cannot have more than one route to send the media content except the LAN.

5 0
3 years ago
Why are there so many unit testing tools? Are they efficient? Why or why not?
sineoko [7]

Answer:

 Unit testing is the software testing method in which the individual source code are associate to control data. Unit testing basically test the code to ensure that the data or information meets its design.

The aim of unit testing that each part isolate in the program and display the correct individual parts.

Unit testing tool are efficient as they provide several benefits in the development cycle. The basic efficiency of unit testing tools depend upon its type of testing. Unit testing basically validate the units of source code in the program.

For example: when the loop and function in the program work efficiently.

5 0
2 years ago
Other questions:
  • Why is it difficult to enforce laws against intellectual theft?
    10·1 answer
  • How to revert a dismissed javascript popup alert box in chrome?
    5·1 answer
  • How can forms help us reduce data-entry errors?
    12·1 answer
  • (1) Output a menu of automotive services and the corresponding cost of each service. (2 pts)Ex:Davy's auto shop servicesOil chan
    9·1 answer
  • What might happen if the internet use policies were broken at your school
    11·2 answers
  • The process in which a server is partitioned into smaller components virtually.
    9·1 answer
  • You need to subnet a network that has 5 subnets, each with at least 16 hosts. Which classful subnet mask would you use?A. 255.25
    12·1 answer
  • Who is the first British in Europe ​
    10·1 answer
  • Draw a flow chart to access the marks of three students. calculate the total avarage and display the result​
    11·1 answer
  • Why should you make sure the paper being used in a printer is dry and not damp?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!