Question: Write a function that accepts a string parameter containing a list of numbers and prints the sum of these numbers as follows (this is not

Write a function that accepts a string parameter containing a list of numbers and prints the sum of these numbers as follows (this is not a regular sum so read instructions carefully):

A) you do not know how many numbers,

B) all the numbers must be on the same input line.

C) some numbers may not have decimal places

For each number: the function will remove any fraction digit more then one decimal place.(example: 10.8756942 ---> 10.8) do not round

The function will then add those numbers and display the result.

Example: (note: original sum would've been 74.9813)

given string s = "10.8787 12.7256 10 5.698 3.446 11 12 5.787";

The function will display:

These numbers are:

10.8 12.7 10 5.6 3.4 11 12 5.7

The sum is: 71.2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!