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
svetoff [14.1K]
4 years ago
6

AddAll - Adds all the doubles in the string with each other. Note every double is separated by a semi-colon. AddAll("1.245;2.9")

=>4.145 double AddAll(const char* str) struct Sale char Person[100]; double sale; double tax; struct SaleStatistic double average Sale; double totalSale; double totalTax; (4) AddAl - Adds all the doubles in the string with semi-colon. AddAll("1.245;2.9")=>4.145 double AddAll(const char* str) { ww struct Sale { char Person[100]; double sale; double tax; }; struct SaleStatistic -- double average Sale: double totalSale: double totalTax:
Computers and Technology
1 answer:
ludmilkaskok [199]4 years ago
3 0

Answer: provided below

Explanation:

The code is provided below/

// the method to add all double value in the string

double AddAll(const char *str)

{

double total = 0;

vector<string> vec;

 

stringstream strStream(str);

 

while (strStream.good())

{

string substr;

getline(strStream, substr, ';');

vec.push_back(substr);

}

 

for (size_t i = 0; i < vec.size(); i++)

{

total = total + stod(vec[i]);

}

return total;

}

 

Program code with addition of the above for testing is provided thus

#include <iostream>

#include <sstream>

#include <vector>

using namespace std;

//addin all double value in syring

double AddAll(const char *str)

{

double total = 0;

vector<string> vec;

 

stringstream strStream(str);

 

while (strStream.good())

{

string substr;

getline(strStream, substr, ';');

vec.push_back(substr);

}

 

for (size_t i = 0; i < vec.size(); i++)

{

total = total + stod(vec[i]);

}

return total;

}

int main()

{

//method calling and display result

cout<<AddAll("1.245;2.9");

}

This gives output as:

4.145

You might be interested in
He ____ is the section of a cpu core that performs arithmetic involving integers and logical operations.
Gelneren [198K]
Arithmetic/logic Unit (ALU)
3 0
3 years ago
A rookie programmer has just typed over 1000 lines code into the command line interpreter for a project that is due the next day
Kipish [7]

Answer:

I believe the answer is ''You have to remove all code from the interpreter before closing it'.

Explanation:

3 0
3 years ago
Pa help po brainliest po kayo kon may nakita ako ng brainliest at mag wait kayo nga i brainliest kailangan ko ngayon please, hel
notka56 [123]

Answer:

hi

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

good evening

8 0
3 years ago
HELP PLEASE!!! Which development method is best explained in this way: a creation of a prototype model that will eventually be d
DerKrebs [107]

Answer:

Not sure but I think its Rapid Prototyping Method

4 0
3 years ago
Which soil horizon has the most organic material?<br><br> O<br> A<br> B<br> C
denis23 [38]
THE CORRECT ANSWER IS a
3 0
4 years ago
Read 2 more answers
Other questions:
  • Which best describes a paraphrase?
    13·1 answer
  • Briefly describe the interface between the memory and the processing unit. That is, describe the method by which the memory and
    6·1 answer
  • The domain name service (dns is a distributed database that allows users to communicate with each other computers by:
    7·1 answer
  • Why is outfitting a workspace with video games in technology development company considered a strategic use of money
    8·2 answers
  • Olivia started working last year. By April 15th, she will need to prepare and send the Federal government _____.
    15·2 answers
  • Consider the following code segment:
    14·1 answer
  • What is a trojan horse in computer science?
    15·1 answer
  • The
    12·2 answers
  • To uncompress the data back into its original binary state, you simply reverse the process. This technique is an example of what
    7·1 answer
  • 5. List three safety concerns when using hand<br> ertain safety<br> tools.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!