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]
3 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]3 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
The roman structure that features heavy use of arches and columns is the _______.
lara31 [8.8K]
The appropriate response is colosseum. It is otherwise called Coliseum and Flavian Amphitheater is an oval amphitheater in the focal point of the city of Rome, Italy. Worked of cement and sand, it is the biggest amphitheater at any point assembled.
8 0
4 years ago
Which option of ms-word is used o represent data in an organised manner?
tekilochka [14]
Use the charting features of Word 2007 and Excel 2007 to present<span> your </span>data<span> in a pie, line, </span>
3 0
3 years ago
Angelika just submitted her product for the first time, and she had 2 errors, 3 warnings, and 5 notifications. What does she nee
KonstantinChe [14]

Answer:

Errors.

Explanation:

Angelika should focus on fixing the errors so that her ads can be shown. Because of the errors the code will not compile fully either be it run time error or compile time error or syntax error or any other error.

Warnings shows the potential problems but the code will run even if there are warnings and the notifications are not to worry about.

4 0
3 years ago
Why did utf 8 replace the sac character encoding standard
Sedaia [141]
UTF-8- is a variable width character encoding capable of encoding all 1,112,064 valid code points in Unicode using one to four 8-bit bytes. The encoding is defined by the Unicode standard. The sac character encoding method was addressed to simplify the symbolism of letter and symbols.As the computers grew in capacity UTF-8 method was implemented to optimize such protocol allowing more characters to be included with an expanded string of possibilities
7 0
4 years ago
1) What is Database? List its Uses.<br>​
Serggg [28]

Answer:

a database stores a large sum of data

Explanation:

its used to keep track of things like student names bank accounts and other things

7 0
2 years ago
Other questions:
  • OBJECTIVE This project will familiarize you with the use of pthreads, pthread mutexes and pthread condition variables. Your prog
    9·1 answer
  • Terrance is working on a new document when he realizes that he would like to use a formatting system that he built in an old doc
    13·1 answer
  • Give two reasons why cloud computing could be harmful to an organization.<br> (No choices!)
    15·1 answer
  • Modern ancestor of the typewriter
    12·2 answers
  • Which kinds of Internet content do you think you need permission to use? Check all that apply.
    8·2 answers
  • Microsoft Windows is the least used operating system. TRUE or FALSE.
    13·1 answer
  • Question 7 (1 point)<br> Increasing hue levels means increasing saturation.<br> True<br> False
    11·1 answer
  • For what reasons do readers use text-to-speech tools? Check all that apply.
    8·2 answers
  • Catherine is designing the backup strategy for the new private cloud that her company is implementing. She specifies that a full
    13·1 answer
  • HEPME <br> ZOOM<br> IN <br> STOP<br> GIVIJG<br> ME <br> LINKS <br> !!
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!