Answered step by step
Verified Expert Solution
Question
1 Approved Answer
10. Write a function named placeStringToRow that takes a string storing a place-string as its only parameter and returns the row number as an int.
10. Write a function named placeStringToRow that takes a string storing a place-string as its only parameter and returns the row number as an int. The function should ignore the first character in the place-string and attempt to convert the remaining characters to a number. - Reminder: Put the function prototype before the ma in function and the function itself at the end of the file. - Reminder: In a well-formed place-string, all characters except the first one give the row number. For example, if the string is " C13, the row number is 13 . Also, in the case of a string with an incorrect first character followed by a number, e.g., "\# 45 " or " 345 ", the function should still return a row number, e.g., 45 . - Hint: Use your stringToInteger function. - Hint: You can get use the . substr function to get only part of a string. For example, str. substr (3) returns a copy of str with the first three characters removed. 11. Add code to your main function to test your placestringToRow function. Write at least 3 tests on different place-strings, including at least one where the row number has multiple digits. For each test, print a message saying the place-string you are testing and the row. 12. Improve your placestringToRow function to handle place-strings that are too short. If the place-string contains fewer than two characters, always return INVALID_COORDINATE. In your main function add a test on an ill-formed place-string. - Hint: You should check the length before doing anything else in the function. If the string is empty and you access position 0 of the string, then your program may crash
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started