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
For window 7 explain the steps you will use to find the available program you will list.
Alex_Xolod [135]
Follow these steps.
1. Make sure that your pc is on.
2. Press your Window key - on your bottom left of your keyboard you will see a window key. 
3. After pressing it will show a tab on your bottom left of your monitor.
4. On that tab you will see an (All Programs) text.
5. Click it and it will show all programs available on your pc.
8 0
3 years ago
A website's _____ is usually the simplest version of the _____ of its homepage. A) hyperlink :FTP B) web server; HTML C)domain n
kaheart [24]

Answer:

B

Explanation:

7 0
3 years ago
Xavier wants to use a solver to find optimal solutions for a decision problem. What should he select as X in the series of click
Marta_Voda [28]

Answer:

The answer is "Analyze"

Explanation:

The term Analyze is the use of a machine or critical thinking to enable more effective management by companies and their information systems, in which the Xavier wishes to use a method for solving to find ideal decision-making strategies. Its object of the series analyses X selects, that's why the "Analyze " is correct.

7 0
3 years ago
What is curated content?
disa [49]

Answer:

Content from the web that has been sorted through and shared on a brand’s digital platforms.

Explanation:

This type of content is created by other organizations but shared by a brand because they believe it will be of interest to their audience.

RIP 999

6 0
2 years ago
Differentiate hardware andsoftware interrupts?
Tom [10]

Answer:

-Hardware interrupts are the interrupts that occur due to the external devices.

-Software interrupt arises due to the executing program.

Explanation:

  • Hardware Interrupts are the raised due to external hardware devices whereas the software interrupts are raised by the executing instruction.
  • Asynchronized events occur in the hardware interrupts whereas software interrupt face the synchronized events.
  • There is increase in the program counter in software interrupt but no increment in the program counter for the hardware interrupt.

8 0
2 years ago
Other questions:
  • A _____ is a device that not only provides surge protection, but also furnishes desktop computers and network devices with batte
    7·1 answer
  • Sorry to bother you guys but for some reason it wont let me comment. How can i fix this?
    5·2 answers
  • Gathering information with your eyes is called
    13·2 answers
  • Omega Software Inc. is currently running a training program for employees to upgrade their software skills so that they are able
    10·1 answer
  • "Which of the following is not an example of a project? Select one: a. Creating a website for a company b. Raising money for a d
    5·1 answer
  • How has your perspective changed since the beginning of the class?
    5·1 answer
  • A Consider the following method definition. The method printAllCharacters is intended to print out every character in str, start
    11·1 answer
  • Write a function that reads from a file the name and the weight of each person in pounds and calculates the equivalent weight in
    12·1 answer
  • Type of Factor Beginning Frog Count Simulation 1 (Low) Simulation 2 (High)
    13·1 answer
  • What is one problem caused by spending too much time studying at your computer? A. It increases stress and negatively affects yo
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!