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
DedPeter [7]
3 years ago
7

The intention of this problem is to analyze a user input word, and display the letter that it starts with (book → B).

Computers and Technology
1 answer:
yulyashka [42]3 years ago
3 0

Answer:

Here is the C++ program:

#include<iostream>  // to use input output functions

using namespace std;     //to identify objects like cin cout

void StartChar(string str)  {  // function that takes a word string as parameter and returns the first letter of that word in capital

   int i;  

   char c;

   do  //start of do while loop

   {

   for (int i = 0; i < str.length(); i++) {  //iterates through each character of the word str

       if(str.length()>25){  //checks if the length of input word is greater than 25

           cout<<"limit exceeded"; }  //displays this message if a word is more than 25 characters long

      c = str.at(i);   // returns the character at position i

       if (! ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) ) ) {  //checks if the input word is contains characters other than the alphabet

            cout<<str<<" is not a word!"<<endl; break;}  //displays this message if user enters characters other than the alphabet

        if (i == 0) {  //check the first character of the input word

           str[i]=toupper(str[i]);  //converts the first character of the input word to uppercase

           cout<<str<<" starts with letter "<<str[i]<<endl;  }  // prints the letter that the word starts with in capital letter

   }   cout<<"Enter a word: ";  //prompts user to enter a word

      cin>>str;   //reads input word from user

}while(str!="#");   }    //keeps prompting user to enter a word until the user enters #

int main()   //start of the main() function body

{ string str;  //declares a variable to hold a word

cout<<"Enter a word: "; //prompts user to enter a word

cin>>str; //reads input word from user

   StartChar(str); }  //calls function passing the word to it

     

Explanation:

The program prompts the user to enter a word and then calls StartChar(str) method by passing the word to the function.

The function StartChar() takes that word string as argument.

do while loop starts. The for loop inside do while loop iterates through each character of the word string.

First if condition checks if the length of the input word is greater than 25 using length() method which returns the length of the str. For example user inputs "aaaaaaaaaaaaaaaaaaaaaaaaaaa". Then the message limit exceeded is printed on the screen if this if condition evaluates to true.

second if condition checks if the user enters anything except the alphabet character to form a  word. For example user $500. If this condition evaluates to true then the message $500 is not a word! is printed on the screen.

Third if condition checks if the first character of input word, convert that character to capital using toupper() method and prints the first letter of the str word in capital. For example if input word is "Computer" then this prints the message: Computer starts with the letter C in the output screen.

The program keeps prompting the user to enter the word until the user enters a hash # to end the program.

The output of the program is attached.

You might be interested in
In your own words explain how to add footer and head in a word doc.
stiks02 [169]

In google docs:

  1. Go to Insert on the Navigation Bar
  2. Go to "Header and Page Number"
  3. Press "Header" or "Footer" depending on your situation

3 0
3 years ago
Examine the exhibit above. "Device A" is an 8-port layer 2 managed switch and "Device C" is a 4-port hub. Which of the following
Harlamova29_29 [7]

Answer:

Device B is Router.

Explanation:

Router is the device that is used to connect different networks to communicate with each other to make possible for all devices of all networks to communicate with each other that are connected to that particular network.

In above case, Device A is 8 port switch that makes a network of 8 different computers. Device C is a 4 port hub that is connected with 4 computers. Both Device A and Device C are different Networks, router is used to connect both all devices of both networks so that they can communicate each other. So the Device B should be router.

6 0
2 years ago
Since the rules cannot address all circumstances, the Code includes a conceptual framework approach for members to use to evalua
Veseljchak [2.6K]

Answer:

more than one safeguard may be necessary.

Explanation:

The conceptual framework can be used to developed as well as construct through a process of the qualitative analysis. The approach includes the in the frameworks for identifying and evaluating the threats to compliance with the rules.

But since the rules formed cannot always address all the circumstances, the Code includes to evaluate the threats to the compliance of more than one safeguards that are necessary.

8 0
3 years ago
a. Do you think the U.S. government should censor information on the Web, such as instructions for making weapons, to protect th
MrRissso [65]

Answer:

The answer is YES.

Explanation:

<em>Things pertaining to weapons, destructive materials should be shared with precautions or much better if these things should not be put online. Since internet is widely available to almost all types of users and almost to all places, we cannot be sure of who will get hold of these information. Kids could easily see this and gain knowledge and out of curiosity will try these dangerous things. Terrorist groups will also have access to these information and who knows might happen to poor innocent souls around.  </em>

<em> </em>

<em>I don't think it would violate the right of First Amendment regarding freedom of speech. Freedom should be granted on matters that are most sensible. And this time, we are just protecting the rights of children and other innocent people who can be a victim including you. We are talking about weapons and destructive materials here which is non beneficial if one could get hold of this information, in my opinion. If there is really a need to construct these things, it is better to consult an expert or an authority to ensure that nobody gets harm.</em>  

5 0
3 years ago
How to find how much storage is left on pc?
FinnZ [79.3K]
Go to your general settings and click on data usage and it should show you how much storage is left.
6 0
3 years ago
Other questions:
  • What is the analysis stage in System development life cycle?
    12·1 answer
  • Computer piracy occurs when what is violated
    6·1 answer
  • A computer virus is a program that can copy itself and infect a computer without the permission of the owner. How do you think a
    9·1 answer
  • When does a soft page break occur in a document
    9·1 answer
  • The memory used by the CPU to temporarily hold data while processing is called _______. random access memory central processing
    5·1 answer
  • A new thread begins its life cycle by transitioning to the ________ state. Group of answer choices new runnable waiting terminat
    9·1 answer
  • What defines the scope of a project?
    5·1 answer
  • What is one way object-oriented programming differs from procedural programming?
    15·1 answer
  • The direction of a ratchet is reversed by _______________________.
    14·1 answer
  • 1) Coding for Table in Html<br>​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!