restructured control flow to method chaining and fixed syntax of if/else statements based on Scanner input.