Write the same code using the designed loop structure. You are not writing complete programs!
Declare a string variable and ask the user to enter a line of text. This process should continue until the user enters the word “done”. Write a while loop and a do while loop that accomplishes this task.
```
//with a while loop
string userStr = "";
while(userStr != "done")
{
cout << "\n Enter some text, \"done\" when finished: ";
getline(cin,userStr);
cout << "\n the text was " << userStr << endl;
}
//with a do while loop
string userStr2;
do
{
cout << "\n Enter some text, \"done\" when finished: ";
getline(cin,userStr2);
cout << "\n the text was " << userStr << endl;
}while(userStr2 != "done");
```
You might also like to view...
The ability to manage information is the mark of a successful systems analyst and an important skill for all IT professionals.
Answer the following statement true (T) or false (F)
For 802.11, the LLC sublayer follows the IEEE 802.2 standard and the flow control/error management (CSMA/CA protocol) is part of this sub-layer.
a. true b. false
Another name for binary expressions is multiplicative expressions.
Answer the following statement true (T) or false (F)
Information securityincludes measures that protect and defend information and information systems by ensuring their availability, integrity, authentication, confidentiality, and nonrepudiation.
Answer the following statement true (T) or false (F)