10.11 Exercises


10.11 Exercises

  1. Design and implement a class that inputs a string and creates a copy of the input string with the characters in reverse order.

  2. Design and implement a class that inputs a long string and counts the number of times that the word "and" appears; the class should display this number on the console.

  3. Design and implement a class that inputs a string and checks if the string is a palindrome; if so, it displays the message "is a palindrome" on the console. A palindrome is a string that does not change when the characters are changed to reverse order.

  4. Design and implement a class that inputs a string and checks if the string starts with the substring "Mr. " or with the string "Mrs. ". Note the space after the dot. If the input string does not include any one of these substrings, the class should display a message.

  5. Design and implement the solution to a problem that sets up an array of objects of class Person. The solution should carry out a binary search of the name of the objects looking for a specific string value (the target string). Hint: modify class Marrayperson in Chapter 9.

  6. Design and implement a solution to a problem that rearranges an array of objects of class Person. For this, use selection sort. Hint: modify class Marrayperson in Chapter 9.

  7. Redesign and reimplement the solution for Exercise 6 with an array parameter definition in the function. Use the appropriate call to the function.




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net