Solving for x and determining costs