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
A social media site violates its terms of service by selling information about its users
balu736 [363]
A company violating its terms of service by selling their user’s info is a violation of Digital Privacy
4 0
3 years ago
Write an if statement that prints the message ""The number is not valid"" if the variable distance is outside the range 100 thr
Slav-nsk [51]

Answer:

The solution code is written in Python:

  1. if(distance < 100 or distance > 2000):
  2.        print("The number is not valid")

Explanation:

In this question either one of the two conditions (distance < 100 or distance > 2000) is met, the error message should be generated. Python offers the "or" keyword as a logical operator. The "or" keyword will join two conditions and so long as one of them is True, the final outcome will be evaluated to True. For example, if distance = 90 the error message will be printed. If distance is 2500, the error message will also be printed.

5 0
4 years ago
What hernia repair codes can be reported with add-on code 49568?
Zolol [24]

This is a multiple choice question. The multiple choices are as follows;

a.49555-49557

b.49654-49659

c.49560-49566

d.49570-49572

Answer is C

Using CPT codebook for 49568, under code 49568, the parenthetical instructions states that coders should report +49568 in conjunction with (49560, 49561, 49565, 49566) when the surgeon repairs a ventral hernia or a incisional.  

 

3 0
4 years ago
. what action does the following a default operator perform? int a, b, c; a = b + c;
PIT_PIT [208]

Answer:

The code defines 3 integers a, b and c, then defines a as the sum of b and c.

Explanation:

In the programming language C int data type is used to declare an integer variable, that is, it can store only both negative or positive integers. I will leave a complete example about it:

#include <conio.h>

#include <stdio.h>

int main()

{

   int a, b, c;

   printf( "\n   Introduce first integer (entero): " );

   scanf( "%d", &b );

   printf( "\n   Introduce second integer (entero): " );

   scanf( "%d", &c );

   a = b + c;

 

   printf( "\n   The sum is: %d", a );

 

   getch(); /* Pause */

   return 0;

}

   

4 0
3 years ago
SIKILDIM OF NAPİM TÜRK OLAN VARMI
vekshin1

ben varım
bende sıkıldım ya

8 0
3 years ago
Other questions:
  • Instructions: Type the correct answer in the box. Spell the word correctly.
    5·2 answers
  • You want to use a wireless keyboard and mouse with your laptop computer. which method should you use
    11·1 answer
  • A cell reference with only one dollar sign before either the column or the row is called an absolute reference.
    10·1 answer
  • A "start transaction" is set to be the system's first screen displayed once you log in to GCSS-Army. Setting up a start transact
    14·1 answer
  • What is the education level of a majority of the Power, Structural, and Technical Systems workers?
    7·1 answer
  • Write a loop that displays all possible combinations of two letters where the letters are 'a', or 'b', or 'c', or 'd', or 'e'. T
    10·1 answer
  • LAB: Even/odd values in an array
    9·2 answers
  • Organizational Units are typically configured to: prevent companies from sharing resources. ensure that the system password is t
    13·1 answer
  • WILL GIVE BRAINLIEST
    5·2 answers
  • 2.20 Write an expression involving a three-letter string s that evaluates to a string whose characters are the characters of s i
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!