The lean and mean

Pocket calculator

 

The program should read in a text string containing a list of numbers separated by + or - and output the sum. The program should also tell how many positive numbers and how many negative (subtracted) numbers there are.

Example:
input:   8.4 + 2.6 - 3.5 + 1
output: result = 8.5, positive numbers: 3, negative numbers: 1.

The input cannot contain any other operators than + and -. Spaces are allowed.

The program should be organized so that main  reads the input as a single text string and outputs the results. The interpretation of the text string and calculation of results should be in a separate sub-function. Do not use global variables.

Tip: the function  atof  can read a number from a text string. Anything that comes after the number is ignored by  atof.