1 answer

//wrigte a program that read continuously word (string)from the user until string "end" the number (string)of...

Question:

//wrigte a program that read continuously word (string)from the user until string end the number (string)of word t the numb

//wrigte a program that read continuously word (string)from the user until string "end" the number (string)of word t the number (string)of word e the short word (string) and it number of character

Answers

IN C++ !!

#include <iostream>

#include <string>

#include <vector>

using namespace std;

int main()

{

string userInput;

vector<string> words;

cout << endl << "Enter words (end to quit): " << endl;

do

{

cin >> userInput;

if(userInput.compare("end") == 0)

break;

else

{

words.push_back(userInput);

}

}while(userInput.compare("end") != 0);

// count the number of words that start with 'T' or 't'

int countT = 0;

for(int i = 0; i < words.size(); i++)

{

if(words[i][0] == 'T' || words[i][0] == 't')

countT++;

}

cout << endl << "Number of words starting with T/t = " << countT << endl;

// count the number of words that start with 'E' or 'e'

int countE = 0;

for(int i = 0; i < words.size(); i++)

{

if(words[i][0] == 'E' || words[i][0] == 'e')

countE++;

}

cout << endl << "Number of words starting with E/e = " << countE << endl;

// find the shortest word and the number of characters in it

vector<int> wordLength;

int index = 0;

for(int i = 0; i < words.size(); i++)

{

wordLength.push_back(words[i].length());

}

int min = wordLength[0];

for(int i = 0; i < wordLength.size(); i++)

{

if(wordLength[i] < min)

{

min = wordLength[i];

index = i;

}

}

cout << endl << "The shortest word is \"" << words[index] << "\" with " << min << " characters." << endl;

return 0;

}

******************************************************************** SCREENSHOT *******************************************************

Enter words (end to quit): clever stunning taller tower egg eggwhite Ego Am end Number of words starting with T/t 2 Number of

.

Similar Solved Questions

1 answer
Please answer question 2 and 3. for question 2, please do not say Brady’s reagent. for...
please answer question 2 and 3. for question 2, please do not say Brady’s reagent. for question 3, we did the reaction with N,N-dimethylaniline and sulfanilic acid. thanks in advance! 2. Provide any two identification tests to differentiate aldehydes and ketones. Write an example for each...
1 answer
Part A, B, and C <Chapter 17 Problem 17.66 ③ got to Review Part A Acharge...
Part A, B, and C <Chapter 17 Problem 17.66 ③ got to Review Part A Acharge of -2.80 nC is placed at the origin of an ty-coordinate system, and a charge of 2.35 nC is placed on the yaxis at y = 3.75 cm. If a third charge, of 5.00 nC, is now placed at the point 2.90 cm.3.75 cm find the cand...
1 answer
Hello! I am struggling to figure the answer to A and B.. Would really appreciate if...
Hello! I am struggling to figure the answer to A and B.. Would really appreciate if someone could help me. Thank you!...
1 answer
Can atoms of some elements can share three pairs of electrons?
Can atoms of some elements can share three pairs of electrons?...
1 answer
(6 points) A company purchased a machine costing $750,000 (plus 5% in taxes) on January 1,...
(6 points) A company purchased a machine costing $750,000 (plus 5% in taxes) on January 1, 2015. Its estimated salvage value is $80,000 and its expected life is 10 years. It cost the company $90,000 to install and make the machine ready for full use. Instructions Record the depreciation expense by e...
1 answer
I've created a mortgage calculator and the next step in my project is to include an...
I've created a mortgage calculator and the next step in my project is to include an array. I'm not very good at C++ as this is my first time taking a programming course. I was able to get this working but I'm confused as to where I could use an array. I was thinking of maybe using the pe...
1 answer
Problem 1. (Consumption smoothing) A consumer who lives for four periods have the following path of...
Problem 1. (Consumption smoothing) A consumer who lives for four periods have the following path of income y 60 0 60 0 Assume the consumer has log utility, a ct) 0 so that the real rate of return is 1 Inq, and is infinitely patient, β-1. Also aKsune the interest rate is (a) What is the optimal ...
1 answer
1) X Corporation reported the following data for the month of August: Inventories: Beginning Ending Raw...
1) X Corporation reported the following data for the month of August: Inventories: Beginning Ending Raw materials $36,000 $24,000 Work in process $23,000 $17,000 Finished goods $37,000 $55,000 Additional information: Raw materials purchases $69,000 Direct labor cost $94,000 Manufacturing overhead co...
1 answer
A sample of 12 radon detectors of a certain type was selected, and each was exposed...
A sample of 12 radon detectors of a certain type was selected, and each was exposed to 100 pcI/L of radon. The resulting readings were as follows: 105.5 91.4 100.1 91.7 97.0 91.8 97.4 92.9 108.2 100.6 103.8 106.1 in USE SALT (a) Does this data suggest that the population mean reading under these con...
1 answer
Please help 1. Directions for reconstitution of mezlocillin of IV injection: "For IV use reconstitute with...
Please help 1. Directions for reconstitution of mezlocillin of IV injection: "For IV use reconstitute with 30mL sterile water for injection. Each 30 mL of reconstituted solution will contain 3 grams of mezlocillin." The client is to receive 1.5 grams of mezlocillin IV every 6 hours. How many...
1 answer
Constants A point charge q1 =-4.00 nC is at the point : 0.60 m, y =...
Constants A point charge q1 =-4.00 nC is at the point : 0.60 m, y = 0.80 m , and a second point charge q2 = +6.00 nC is at the point x = 0.60 m , y...
1 answer
The musicians guild with 843 members, has two representatives on the national arts advisory board. the...
the musicians guild with 843 members, has two representatives on the national arts advisory board. the artists alliance has 784 members, has seven representatives. if either the musicians or the artists can be given one additional represenrative to the NAAB determine which group should get it using ...
1 answer
QUESTION 6 () Simplify In
QUESTION 6 () Simplify In...
1 answer
Matlab is mathematics programing language.you have to write code of matlab, with your output screen shot...
matlab is mathematics programing language.you have to write code of matlab, with your output screen shot of waveform Problem 6 Matlab: For a baseband message signal m(t) = 5cos(250t), and carrier signal c(t) = cos(2103t). Sketch the FM modulated signal in time domain in the interval (0, 0.1 seconds ...
1 answer
Suppose a risk-free asset has a 5 percent return and a second asset has an expected...
Suppose a risk-free asset has a 5 percent return and a second asset has an expected return of 13 percent with a standard deviation of 23 percent. A portfolio consisting 10 percent of the risk-free asset and 90 percent of the second asset. What is the Sharpe ratio of this portfolio?...