#include <iostream>
#include <string>
#include <sstream>

void print_city_totals( std::istream& input, std::ostream& output )
{
    constexpr char COMMA = ',' ;

    std::string line ;
    while( std::getline( input, line ) ) // for each line input the input stream
    {
        std::istringstream stm(line) ;

        double first ;
        stm >> first ; // get the first number

        stm.ignore( 100, COMMA ) ; // throw away the comma

        std::string city_name ;
        std::getline( stm, city_name, ',' ) ; // read everything upto the comma into name

        double second ;
        stm >> second ; // get thesecond number

        if(stm) output << city_name << ' ' << first+second << '\n' ;
        else output << "[ error in line: '" << line << "' ]\n" ;
    }
}

int main()
{
    std::istringstream input( "15.1,Chico,17.4\n"
                              "34.4,Seattle,30.52\n"
                              "what is this?\n"
                              "2.9,Portland,26.1\n"
                              ".5,Death Valley,1.1\n" ) ;

    print_city_totals( input, std::cout ) ;
}
