Serial input manipulation

You are facing a simple task. Collect characters until you find a new line. Once a new line is found, look at what you got and get a number out of it. Think about how to do part one and part two only needs one line. I'll be waiting gift part one answer before I give out part two answer.