Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

Has the team been empowered to prioritize the issues?

Answered: 1 week ago