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
Blababa [14]
3 years ago
5

Write code that inserts userItem into the output string stream itemsOSS until the user enters "Exit". Each item should be follow

ed by a space. Sample output if user input is "red purple yellow Exit":
Computers and Technology
1 answer:
My name is Ann [436]3 years ago
3 0

Answer:

<h2>C++ Code:</h2>

#include <iostream>  //header file for input output functions like cout cin

#include <sstream>  // reads from string as a stream

#include <string> // header file for strings

using namespace std;   //  used for computer to detect  endl cout, cin

int main() {  //start of the main function of the program

string userItem;  // declare string type variable

ostringstream itemsOSS;   // output string stream    

cout << "Enter items (type Exit to quit):" << endl;  

// prompts user to enter items and type Exit to quit

cin >> userItem;   //reads input userItems

while (userItem != "Exit") {   //loop that runs untill userItem gets equal to Exit

itemsOSS << userItem << " ";

  // inserts userItem into the output string stream itemsOSS

cin >> userItem; }   //reads items stored in userItem variable

cout << itemsOSS.str() << endl;}   // prints current contents of the itemsOSS.                                                                                              

<h2>Explanation:</h2>

I will explain the code line by line.

  • The first line includes a header file iostream which is used for input and output functions such as cin, cout etc.
  • The next line includes sstream header file to read from a string as a stream. String streams are streams containing strings. Strings are treated like streams and stream operations are used on these strings.
  • The next line includes string header file in order to use strings in the program.
  • Next line namespace is used for the computer to identify objects like endl, cin, cout.
  • This lines starts the main function and enters the body of main function.
  • A string type variable userItem is declared.
  • ostringstream type variable itemsOSS is declared. ostringstream class works on strings.
  • This line prompts the user to enter the items and type Exit word to quit. endl is used to insert new line.
  • This line read input from variable userItem which is inserted by the user.
  • This statement starts a loop which will continue to execute until the user types Exit.
  • In the body of while loop, this line shows that the items entered by the user  in userItem will be inserted into the output string stream itemsOSS. Every userItem is followed by a space. << this is insertion operator. This retrieves items from the input sequence and inserts them into the itemsOSS, until Exit is typed.
  • Next line reads items stored in userItem variable.
  • str() returns a copy of the string which is manipulated by the current stream string and it outputs the contents of the itemsOSS stream.
<h2>Output:</h2>

Enter items (type Exit to quit):

red purple yellow Exit

red purple yellow

You might be interested in
In basic network scanning, ICMP Echo Requests (type 8) are sent to host computers from the attacker, who waits for which type of
Hoochie [10]

Answer:

d. ICMP Echo Reply (type 0)

Explanation:

ICMP or internet control message protocol is an Internet layer protocol in the TCP/IP suite. It works together with routing devices like the router to send messages based on results sensed in the network.

The RFC 1122 has stated that the ICMP server and end user application be configured or installed in user devices, for receiving and sending ICMP echo request packets and reply. The process is called pinging.

For an attacker to implement ping of ping, he needs to confirm if the target user in live by sending an ICMP echo request packet type 8, to receive an ICMP echo reply type0.

4 0
3 years ago
IF ANYONE ANSWERS YOUR QUESTION WITH SOMETHING LIKE THIS:
vova2212 [387]

Answer:Thank you very much! A user names SShalomeea has been hacking today. Anyone with that photo is a spammer.

4 0
3 years ago
Read 2 more answers
Transaction processing systems (TPSs) provide valuable input to management information systems, decision support systems, and kn
nadezda [96]

A transaction is a simple task carried out as part of corporate operations. Transaction processing systems (TPS) handle business transactions for the corporation, supporting overall enterprise operations.

A TPS creates papers pertaining to a non-inquiry transaction and records the transaction itself, together with all of its results, in the database.

Today, TPS are required for business operations in practically every firm. TPSs feed information into organizational databases; they also serve as the framework for management-oriented information systems. Source data automation frequently involves direct data entering. Electronic data interchange is being utilized by transaction processing systems more and more. These systems offer computer-to-computer communication without the need for repeated data entry by substituting paper documents with formatted transaction data sent over telecommunications networks.

Learn more about information here-

brainly.com/question/15709585

#SPJ4

5 0
1 year ago
Where does the CPU store its computations
mario62 [17]

Answer:

In main memory

Explanation:

Hope this helps

8 0
3 years ago
Read 2 more answers
____ are diagrams used in mathematics and logic to help describe the truth of an entire expression based on the truth of its par
Bad White [126]
<span>Truth tables are diagrams used in mathematics and logic to help describe the truth of an entire expression based on the truth of its parts.

A truth table shows all the possible combinations (outputs) that can be produced from the given inputs. They are mainly used in Boolean algebra.</span>
4 0
2 years ago
Other questions:
  • While engineers work to create computers that can understand us emotionally, ________ are also evolving toward a more human appe
    12·1 answer
  • ___ Jacking is a crime that takes place when a hacker misdirects URL to a different site. The Link Itself Looks Safe, But the us
    11·1 answer
  • What does computer means?
    13·2 answers
  • This type of technology does not come with a keyboard or mouse for input
    11·2 answers
  • How to fix Please enable JS and disable any ad blocker
    13·2 answers
  • What major criteria must a product or process meet in order to be considered emerging technology?
    7·1 answer
  • When a computer or digital device is used as a storage device or in the facilitation of an offense, it is argued to be ____ to t
    14·1 answer
  • g 'write a function that takes as input a list and outs a new list containing all elements from the input
    5·1 answer
  • How dose society use computer in government?​
    5·1 answer
  • What is the difference between a computer’s RAM and its hard disk?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!