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
A network on the internet has a subnet mask of 255.255.240.0. what is the maximum number of hosts it can handle
Lera25 [3.4K]
It is a class B network, so for a class B network, the upper 16 bits form the network address and the lower 16 bits are subnet and host fields. Of the lower 16 bits, most significant 4 bits are 1111. This leaves 12 bits for the host number. So, 4096(2^12) host address exists. First and last address are special so the maximum number of address is 4096-2=4094.
7 0
3 years ago
A RESTful service, such as the open weather service use used in an activity in this class, sends and receives data in the form o
vfiekz [6]

Answer:

A key/value pair

Explanation:

JSON or JavaScript Object Notation uses key/value pairs to represent data.

Here's an example:

{

   name: "Jordan Carter"

   age: 25

}

Data can be then accessed using a key such as "name" to get the value "Jordan Carter."

8 0
2 years ago
You're the network administrator for several Windows Server 2016 servers in New York. Your company just opened an office in Cali
vredina [299]

Answer:

The time zone on the California server needs to be changed.

Explanation:

A user seems to be the admin in Nyc over several servers running on the following Windows Server. His firm has just established a California branch, so transfer some of the servers to that of the new firm. Its server had been fully operational in less than 2 days of the user sending it. Now that the user has issues in authenticating between both the California server and the Nyc domain controllers.

So, the following issues are occurring in authenticating the servers of both places because the timezone of both places is different and they need to change the time zone on the California server.

5 0
3 years ago
What ion is formed when an atom of mercury (Hg) loses two electrons?
serious [3.7K]
When the atom loses electrons its negative charge decrease so it becomes positive ion the answer: D) Hg+2.
5 0
3 years ago
Read 2 more answers
Our Sun is _____________ the Milky Way galaxy.
romanna [79]
One of many stars in the milky way galaxy
4 0
2 years ago
Read 2 more answers
Other questions:
  • What does raster graphic mean
    5·1 answer
  • Robin ensures that she is always available if anyone in the team needs her. Which quality is shown by robin?
    9·2 answers
  • Write a function called lucky_sevens that takes in one #parameter, a string variable named a_string. Your function #should retur
    15·1 answer
  • When utilizing the Internet Storage Name Service (iSNS), how can you limit which targets iSCSI initiators can discover and conne
    10·1 answer
  • Fedora operating system
    9·1 answer
  • 8. Which of the following could be measured by defining a goal in Google Analytics?
    13·1 answer
  • Consider a system consisting of processes P1 , P2 , ..., Pn , each of which has a unique priority number. Write a monitor that a
    14·1 answer
  • What is Activation code for wwe 2k20 ​
    8·2 answers
  • Which components are involved with input? Output? Processing? Storage?
    15·2 answers
  • 1. Which of the following is not true about high-level programming language s? (a) Easy to read and write (b) Popular among prog
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!