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
In the following nested loop structure, which loop does the program EXIT first?
EleoNora [17]

Answer:

C

Explanation:

4 0
2 years ago
The concept/theory where computer generated animation (especially humans) that is TOO life-like they become uncomfortable to us
Zolol [24]

Answer:

The concept/theory where computer generated animation (especially humans) that is TOO life-like they become uncomfortable to us as viewers instead of likeable cartoons is known as Uncanny valley

Explanation:

The uncanny valley is a concept that was introduced in the 1970s by Masahiro Mori. It is used to describe when a computer generated animated figure bears too much of a resemblance to humans, to the extent that the person viewing it may feel a sense of unease. The animated figure appearing almost human would likely elicit cold and eerie feelings in viewers.

7 0
2 years ago
Read 2 more answers
During early recording, microphones picked up sound waves and turned them into electrical signals that carved a _______ into the
Tcecarenko [31]

Answer:

Groove

Explanation:

There is not much to explain

8 0
3 years ago
Providing incentives for customers to learn more about your service is known as?
Julli [10]
B) Advertising is the answer
3 0
3 years ago
Before donating a computer you should use a program to wipe the hard disk to remove all of its data
Elenna [48]
Yes you should. highly recommended
7 0
2 years ago
Read 2 more answers
Other questions:
  • Please answer this correctly the underline drop down menu in the font group contains options to underline
    13·1 answer
  • Probability can be used to determine the likelihood of specific __________
    6·2 answers
  • When sketching out your Web site you create a clear and straightforward site map that divides the Web site content into a logica
    9·1 answer
  • You are system administrator with hundreds of host workstations to manage and maintain. You need to enable hosts on your network
    14·1 answer
  • Identify a stressor in your life. Conduct an internet search to locate at least two reliable sources of information on effective
    6·1 answer
  • HELP AASAP BRAINLIEST JUST HELP
    13·1 answer
  • WILL GIVE BRAINLIEST!!!!!! 10 POINTS!!!!
    14·2 answers
  • Explain the evolution of programming language​
    15·1 answer
  • Define two benefits to members of the community of replacing the printed copy with an online version.
    5·1 answer
  • Organizations can face criminal or civil penalties for being ______ in protecting their sensitive data.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!