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
To join two or more objects to make a larger whole is to _____________ them.
Masja [62]
C. Integrate is the answer PLZ MARK AS BRAINLIEST
6 0
3 years ago
Read 2 more answers
If wire rope guard rails are used what must also be done?
zzz [600]
A Deceleration device.
A rope, wire rope, or strap with connectors at each end for connecting the 5 point body harness to a lifeline, or anchorage.

Look under OSHA Flashcards on Quizlet and..
OSHA: Fall Protection in Construction, Subpart M and just past that area in the document.

This is from that document on page 13 and 14:  
Fall Restraint Systems:  While fall restraint systems are not mentioned in Subpart M, OSHA recognizes a fall restraint system as a means of prevention. The system, if properly used, tethers a worker in a manner that will not allow a fall of any distance. This system is comprised of a body belt or body harness, an anchorage, connectors, and other necessary equipment. Other components typically include Photo: Skip Pennington OCCUPATIONAL SAFETY AND HEALTH ADMINISTRATION 1 4 a lanyard, a lifeline, and other devices. For a restraint system to work, the anchorage must be strong enough to prevent the worker from moving past the point where the system is fully extended, including an appropriate safety factor. *In a November 2, 1995 interpretation letter to Mr. Dennis Gilmore, OSHA suggested that, at a minimum, a fall restraint system must have the capacity to withstand at least 3,000 pounds or twice the maximum expected force that is needed to restrain the person from exposure to the fall hazard. In determining this force, consideration should be given to site-specific factors such as the force generated by a person (including his/her tools, equipment, and materials) walking, slipping, tripping, leaning, or sliding along the work surface.

8 0
3 years ago
Ontext clues can be used to determine the _____ of an unfamiliar word
Solnce55 [7]
Meaning of the word.

6 0
3 years ago
Need this answered quickly, 40 PTS!
drek231 [11]

Hello,


Answer: In 1965, Gordon Moore noticed that the number of transistors per square inch on integrated circuits had doubled every year since their invention. Moore's law predicts that this trend will continue into the foreseeable future. ... The 18-month mark is the current definition of Moore's law.


Please read and you will have your answer!


If you did not love this answer let me know and I will try again.



7 0
2 years ago
Read 2 more answers
Draw the Abstract Syntax Trees for the following statements and represent them in text form. i) 1+2+3 ii) 6÷3×4+3
MArishka [77]

Answer:

your a legend you can do it just pleave

Explanation:

:)

5 0
2 years ago
Other questions:
  • Show the contents of a queue after the following operations are performed. Assume the queue is initially empty. enqueue(45); enq
    6·1 answer
  • Which connector is most commonly used to connect printers to desktop pc systems?
    10·1 answer
  • How could a system be designed to allow a choice of operating systems from which to boot? What would the bootstrap program need
    14·1 answer
  • What part of a check is the LEAST important?
    14·2 answers
  • Which is an advantage that electronic scheduling tools have over paper calendars?
    13·2 answers
  • An expression involving byte, int, and literal numbers is promoted to which of these?
    12·1 answer
  • What are data structures and algorithms? Why are they important to software developer?
    14·1 answer
  • Complete the steps for adding a recurring event.
    10·1 answer
  • 1) What is Database? List its Uses.<br>​
    15·1 answer
  • Assignment 1:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!