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
pychu [463]
4 years ago
11

Write a program that will read in a line of text and output the number of words in the line and the number of occurrences of eac

h letter. Define a word to b any string of letters that is delimited at each end by either whitespace, a period, a comma, or the beginning or end of the line. You can assume that the input consists entirely of letters, whitespace, commas, and periods. When outputting the number of letters that occur in a line, be sure to count upper and lowercase versions of a letters as the same letter. Output the letters I alphabetical order and list only those letters that do occur in the input line.

Computers and Technology
1 answer:
kherson [118]4 years ago
7 0

Answer:

Here is the C++ program:

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

#include <algorithm>  //to use tolower() function

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

int main() {  //start of main function

 string text;  // to hold text input

 cout<<"Enter a line of text: ";  // prompts user to enter a string

 getline(cin,text);  // reads the input string (text) from user

transform(text.begin(), text.end(), text.begin(), ::tolower);  //converts the text into lower case

 int letter[26] = {0}; //to hold the letters

 int i;  // used as a loop variable

 int words=0;  // to hold the count of words

 for(i = 0; i< text.size();i++){  // iterates through the text

 if(isalpha(text[i])&&(text[i+1]=='.'||text[i+1]==','||text[i+1]==' '))  //checks if the character at i-th index of text is a letter, and checks if i+1 index position of text is a period, comma or a space

 words++;  // adds 1 to the count of words

 if(isalpha(text[i]))  // if the character at the i-th index of text is a letter

 letter[text[i]-'a']++;  }  // counts the occurrences of each letter

 char j = text[text.size()-1];  // sets j to the last character of text

 if(j != '.' && j!= ' '&& j!=',' &&j!= '\0')  //if the last character is not a period or empty space  or comma or end of lone

 words++;  //add 1 to the count of words

 cout<<"Number of words: "<<words<<endl;  //display the number of words in the text

 for(i=0; i<26; i++)  {  //iterates 25 times

   if(letter[i]>0)  //if letter at index i is greater than 0

   cout<<(char)('a'+i)<<" : "<<letter[i]<<endl;  }} //displays each letters and its number of occurrences in the text

 

Explanation:

The program is explained in the attached document with an example.

You might be interested in
6. Why did he choose to install the window not totally plumb?
Dmitriy789 [7]

Answer:

Because then it would break

Explanation:

You achieve this by obtaining correct measurements. When measuring a window, plumb refers to the vertical planes, and level refers to the horizontal planes. So he did not install the window totally plumb

8 0
3 years ago
A downloaded executable file may contain harmful software known as
mylen [45]

Answer:

A downloaded executable file may contain harmful software know as malware.

Further details:

Malwares:

Malware (a portmanteau for pernicious programming) is any product purposefully intended to make harm a PC, server, customer, or PC network. Malware does the harm after it is embedded or brought somehow or another into an objective's PC and can appear as legitimately executable code, contents, supposed "dynamic substance" (Microsoft Windows), and different types of data. Some sorts of malware are to a great extent alluded to in the media as PC infections, worms, Trojan steeds, ransomware, spyware, adware, and scareware, among different terms. Malware has a malignant expectation, acting against the enthusiasm of the PC client—thus does exclude programming that causes accidental damage because of some lack, which is regularly portrayed as a product bug.

Uses:

Malware is once in a while utilized comprehensively against government or corporate sites to assemble monitored information, or to upset their activity as a rule. However, malware can be utilized against people to pick up data, for example, individual recognizable proof numbers or subtleties, bank or charge card numbers, and passwords.

Answer details:

Subject: Computer and technology

Level: College

Keywords:

• Harmful software

• Malware

• Malware software

• Uses of malware

• Purpose of malware

Learn more to evaluate:

brainly.com/question/4997492

brainly.com/question/4010464

brainly.com/question/1754173

8 0
3 years ago
Read 2 more answers
This is a quick and easy program that will let you practice the basics of the switch statement. You will ask the user to enter a
Nikolay [14]

Answer:

Explanation:

oof okay

5 0
3 years ago
PLC software does not typically fail or break​
nydimaria [60]

Answer:

Good to know

Explanation:

:)

7 0
3 years ago
What tool might be used by an attacker during the reconnaissance phase of an attack to glean information about domain registrati
Soloha48 [4]

A tool which might be used by an attacker during the reconnaissance phase of an attack to glean information about domain registrations is: Whois.

<h3>What is a DNS server?</h3>

A DNS server can be defined as a type of server that is designed and developed to translate domain names into IP addresses, so as to allow end users access websites and other internet resources through a web browser.

This ultimately implies that, a DNS server refers to a type of server that translate requests for domain names into IP addresses.

In this context, we can infer and logically deduce that Whois is a tool which might be used by an attacker during the reconnaissance phase of an attack to glean information about domain registrations.

Read more on a domain names here: brainly.com/question/19268299

#SPJ1

4 0
1 year ago
Other questions:
  • In Paint, which of the following are ways to use a picture that you have saved on your computer? (Select all that apply.)
    8·1 answer
  • To order the records in the answer to a query in a particular way, you ____ the records.
    11·1 answer
  • You use a(n) ____ variation when a use case is less specific than others, and you want to be able to substitute the more specifi
    8·1 answer
  • A motherboard uses dual channeling, but you have four DIMMs available that differ in size. The motherboard supports all four siz
    7·1 answer
  • What is a custom information field that helps users to find a specific document?
    8·1 answer
  • You want to copy data from one cell or range to an adjacent cell or range in your spreadsheet, without using a shortcut key. Whi
    10·1 answer
  • Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1, 1990. Any date not
    10·1 answer
  • Because travel distance, cost of living, and other factors vary among the three regions, the annual cost of having a salesperson
    14·1 answer
  • Describe a NIC card and can you have more than one?
    13·1 answer
  • Why is it important for organizations to make strong commitment to Cloud at scale?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!