Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MODIFYING CODE USING C++ Here is what I have to do: Read some text into a vector, storing each word in the input as an

MODIFYING CODE USING C++

Here is what I have to do: Read some text into a vector, storing each word in the input as an element in the vector. Transform each word into uppercase letters. Print the transformed elements from the vector, printing eight words to a line.

Here is what I have so far. But I cannot get the program to stop. I am trying to get the program to terminate after a user inputs DONE.

#include #include #include #include #include using std::cin; using std::cout; using std::endl; using std::istringstream; using std::string; using std::vector;

using namespace std;

int main() { string s; vectorv; cout << "Please enter amount needed for string: "; int amount; cin >> amount; for(int i = 0; i < amount; i++) while (true) { cin >> s; if (s == "DONE") break; v.push_back(s); } for(int i = 0; i < v.size(); ++i) { for(int j = 0; j < v[i].size(); ++j) { if(islower(v[i][j])) { v[i][j] = toupper(v[i][j]); } } } for(int i = 0; i < v.size(); ++i) { cout << v[i] << " "; } return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions

Question

Using Language That Works

Answered: 1 week ago

Question

4. Are my sources relevant?

Answered: 1 week ago