BMW boosts earnings with higher-priced and electric cars