The third person singular verb form in English is distinguished by the suffix -s
ID: 3843781 • Letter: T
Question
The third person singular verb form in English is distinguished by the suffix -s, which is added to the stem of the so-called infinitive form. Verbs given in the infinitive form are typically written with “to” in front, as in “to sleep” or “to walk.” Often we simply add the letter “s” to the infinitive form (as in “sleep” “sleeps” and “run” “runs”), but in other cases we need to modify the end of the word. Here are some simple rules we could consider:
• If the verb ends in y, remove the y and add ies. Example: “cry” becomes “cries”.
• If the verb ends in o, ch, s, sh, or x, add es. Example: “push” becomes “pushes”, and “hiss” becomes “hisses”.
• Otherwise, just add s.
Implement a function singular verb() that takes a verb in its infinitive form (but without “to”) as an argument and converts it to its third person singular verb form according to the rules above. You might find the string function endswith helpful here. Suppose the variable name represents the string "Wolfie". Then name.endswith(’e’) and name.endswith(’ie’) would both evaluate to True, whereas name.endswith(’E’) and name.endswith(’in’) would both evaluate to False.
As we can see, the rules aren’t perfect – “play” should really have been replaced with “plays” to be gramatically correct, but your function will instead return “plaies”.
Examples: Function Call Return Value singular verb wax' waxes' singular-verb type 'types' singular-verb go' goes' singular verb ('play plaiesExplanation / Answer
//Verbs.java
import java.util.Scanner;
public class Verbs {
public static void main(String args[]){
String vb;
//Reading the String value using Scanner
Scanner s = new Scanner(System.in);
System.out.println("Enter the verb in infinite form:");
vb = s.nextLine();
verb(vb); // Passing String into verb method
}
public static void verb(String vb) {
String v="";
String s[] = vb.split(" "); // Splitting if first string is "to"
if(s.length==1){
v=v+vb;
}else{
v=v+s[1]; // Getting String at 1st location if it Contains to
}
// Checking if verb starts with "y"
if(v.endsWith("y")){
// Removing last character and adding ies
v= v.replace(new Character(v.charAt(v.length()-1)).toString(), "ies");
}
// Checking if verb starts with o,ch,s,sh and x
else if(v.endsWith("o") || v.endsWith("ch") || v.endsWith("s") || v.endsWith("sh")||v.endsWith("x")){
StringBuffer sb = new StringBuffer(v);
// Adding "es" to last
sb.append("es");
v=sb.toString();
}
//Else adding s for all other Strings
else{
StringBuffer sb = new StringBuffer(v);
//Adding s to last
sb.append("s");
v=sb.toString();
}
System.out.println("The third person singular verb form of "+vb+" is:"+v);
}
}
Output:
Enter the verb in infinite form:
to sleep
The third person singular verb form of to sleep is:sleeps
Enter the verb in infinite form:
run
The third person singular verb form of run is:runs
Enter the verb in infinite form:
cry
The third person singular verb form of cry is:cries
Enter the verb in infinite form:
push
The third person singular verb form of push is:pushes
Enter the verb in infinite form:
add
The third person singular verb form of add is:adds
Enter the verb in infinite form:
wax
The third person singular verb form of wax is:waxes
Enter the verb in infinite form:
type
The third person singular verb form of type is:types
Enter the verb in infinite form:
go
The third person singular verb form of go is:goes
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.