Answer to Question #255455 in C++ for JacksonCrews

Question #255455

Assignment: Functions


double s_to_d(string) – Converts a decimal number saved as a string to a decimal number saved as a float. Follows the given steps.

1. Create a double accumulator.

2. Find the index i of the decimal point (‘.’).

1. If no decimal point exists, set i to the length of the string.

3. Iterate over each character in the string with the iterator j.

1. If i – j is positive,

1. Pass the current character into c_to_i(char)

2. raise 10 to the power of the i – j – 1 with the myPow(int, int) function.

3. multiply these two results.

4. Add this result to the accumulator.

2. else if i – j is negative,

1. Pass the current character into c_to_i

2. raise 10 to the power of i – j.

3. multiply these two results.

4. Add this result to the accumulator.

4. Return the accumulator.


1
Expert's answer
2021-10-22T18:35:37-0400
Dear JacksonCrews, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS