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
frozen [14]
2 years ago
6

Write a C++ function with the following signature: void readAndConvert() The function takes no parameters and returns no value.

Instead, it reads its input from std::cin and writes its output to std::cout. Both the input and output are information describing a sequence of stock trades, albeit in different formats. Input format The input will be formatted according to the following specification. You may freely assume that the input will be in the format described here; it doesn't matter what your function does with input that doesn't meet those requirements. • The first line of the input will contain a positive integer, which will specify the number of trades whose information will be present in the input. • The second line of the input will contain the stock's symbol, which is a sequence of uppercase letters. • The third line of the input will contain a brief description of the stock, which is any arbitrary sequence of characters. • After that will be one line for each trade - so the integer on the first line tells you how many more lines there will be — which will contain three pieces of information separated by spaces! • A positive integer specifying the number of shares traded. o The price paid for each share, which is a number that will always have exactly two digits after the decimal point. • A sequence of lowercase letters that specifies a confirmation number for the trade. One example input that follows that format is as follows, though your function would need to work on any input that follows the specification, not just the one example. BOO Forever Boo Enterprises 100 50.00 barzxfq. 200 60.75 hhpncstvz 150 7.90 cjjm 175 100.15 fryzyt Output format Your function's output is a reorganization of the information from the input, which you would write in the following format. • The first line of output would contain the description of the stock, followed by a space, followed by the symbol surrounded by parentheses. • Each subsequent line of output describes one of the trades from the input, in the following format: o The confirmation number, followed by a colon and a space, followed by the integer number of dollars spent in the order (i.e., the number of shares times the price per share, always rounding to the floor of the number). The correct output for the example input above is as follows. Forever Boo Enterprises (BOO) barzxfq: 5000 hhpncstvz: 12150 cjjm: 1185 fryzyt: 17526 It is irrelevant whether your program prints all of the output only after reading the input, or whether it prints the output while it reads input; this is your choice. The only requirement is that your output meets the formatting requirements.
Computers and Technology
1 answer:
shepuryov [24]2 years ago
4 0

Answer:

The function is as follows:

void readAndConvert(){

   int n; string symbol,name;

   cin>>n;

   cin>>symbol;

   cin.ignore();

   getline (cin,name);

   vector<string> trades;

   string trade;

   for (int inps = 0; inps < n; inps++){

       getline (cin,trade);

       trades.push_back(trade);}

   

   cout<<name<<" ("<<symbol<<")"<<endl;

   for (int itr = 0; itr < n; itr++){

       string splittrade[3];        int k = 0;

       for(int j=0;j<trades.at(itr).length();j++){

           splittrade[k] += trades.at(itr)[j];

           if(trades.at(itr)[j] == ' '){

               k++;    }}

cout<<splittrade[2]<<": "<<floor(stod(splittrade[1]) * stod(splittrade[0]))<<endl;        }

   }

Explanation:

See attachment for complete program where comments are used to explain each line

Download cpp
You might be interested in
Which of the following BEST describes an extranet?
zimovet [89]

Answer:

D. an Internet connection allowing outsiders limited access to a firm's internal information system

Explanation:

An extranet is a private network that allows partial access to a company's network to partners, services providers, and selected customers. It provides a secure way of information exchange between the business and its stakeholders. An extranet is comparable to a Demilitarized Zone (DMZ) in that it gives authorized parties access to needed services but not the whole network.

8 0
3 years ago
Fill in the blanks to complete a summary of this part of the passage. For the power of Patents
PIT_PIT [208]
I’m confused . what do i do?
6 0
2 years ago
Read 2 more answers
Define the term hardwar<br><br>​
bezimeni [28]

Answer:

tools, machinery, and other durable equipment.

Explanation:hardware in a computer are the keyboard, the monitor, the mouse and the central processing unit.

4 0
2 years ago
Read 2 more answers
What kind of memory modules include registers between the system’s memory controller and the module’s memory chips, registers th
Nookie1986 [14]

Answer: Buffered

Explanation: Buffered memory is the memory contains registers between the modules of dynamic random access memory(DRAM).It is also known as registered memory. The purpose of using buffered memory to increase the stability and decrease the electrical load.

Other options are incorrect because ECC(error correcting code)memory is for correction and detection of incorrect data, non- parity memory is that don't utilize ECC module and multi-channel used for the increment in the rate of transmission between memory controller and DRAM.

Thus,the correct option is option buffered memory because of serial communication pattern with memory controller and parallel communication technique with chips .

4 0
3 years ago
Read 2 more answers
________ employees state-of-the-art computer software and hardware to help people work better together.
natulia [17]

The correct answer is collaborative computing

Using state-of-the-art computer software and hardware to help people work better together is known as collaborative computing. Goal setting and feedback will be conducted via Web-based software programs such as eWorkbench, which enables managers to create and track employee goals.

6 0
3 years ago
Other questions:
  • What lie does E.D. tell to keep the musical from being canceled? There is a television crew coming to do a story on it. Jake wil
    6·1 answer
  • What cable should i be using to connect my android tablet to the pc?
    13·2 answers
  • You can write as many constructors for a class as you want, as long as they all have different ____ lists.
    8·1 answer
  • What is computer hacking?
    11·2 answers
  • Which tab provides commands for the most commonly used elements in Word software?
    15·1 answer
  • the part of the computer that contains the brain , or central processing unit , is also known the what ?
    12·1 answer
  • True or false: when an ospf route sends its link state information, it is sent only to those nodes directly attached neighbors.
    14·1 answer
  • Networking and telecommunications technologies, along with computer hardware, software, datamanagement technology, and the peopl
    11·1 answer
  • Document accurately describes the differences between servers and computers and between local and wide area networks. Document p
    5·1 answer
  • KELLY Connect
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!