xhtml
 

Exercise 13: Plurals

A program is needed for checking whether plurals are used correctly. It should take two words which form a phrase like two chairs with a small number followed by a noun. It should check that if the first word is one then the second word should not end with an s but otherwise it should.

The program has been started for you as usual. The tests are already in place, so it is just print statements that have to be added to give the output right or wrong.

As well as s1.equals(s2) to compare two strings, the tests also use s1.endsWith(s2) to test whether one string ends with another. You can look up the endsWith method in the Java documentation, by looking in the java.lang package, and then the String class.


Back