PluralCheck.java
This program was created to check if the words in a string are plurals that end with the letter s.
Unfortunately, the name of the program is utterly misleading as there are words that are plural that don’t require a letter s at the end such as Geese, Mice, and Moose (plural of Moose is Moose).
The code has been modified slightly and now uploaded to the site.
Code Snippet
// Link: https://edabit.com/challenge/pzLMEsMpbCLsPXqy2
public class PluralCheck {
public static void main(String[] args){
boolean result = isPlural("changes");
boolean result2 = isPlural("change");
boolean result3 = isPlural("dudes");
boolean result4 = isPlural("magic");
System.out.println(result);
System.out.println(result2);
System.out.println(result3);
System.out.println(result4);
}
public static boolean isPlural(String word){
boolean check = false;
if (word.endsWith("s")){
check = true;
}
return check;
}
}
Here is the abysmal JOptionPane Java GUI version.
JOptionPane Code Snippet
import javax.swing.JOptionPane;
public class PluralCheckGUI {
public static void main(String[] args){
boolean checker = true;
JOptionPane.showMessageDialog(null, "Welcome!\nPress enter to continue...");
while (checker == true){
String input = JOptionPane.showInputDialog(null, "Please enter a word to check if it's plural or with an s at the end!\nPress the X to exit on the top right!");
boolean inpResult = isPlural(input);
//boolean result = isPlural("changes");
//boolean result2 = isPlural("change");
//boolean result3 = isPlural("dudes");
//boolean result4 = isPlural("magic");
JOptionPane.showMessageDialog(null, "Is the word plural or with an s? " +inpResult);
//System.out.println(result);
//System.out.println(result2);
//System.out.println(result3);
//System.out.println(result4);
}
}
public static boolean isPlural(String word){
boolean check = false;
if (word.endsWith("s")){
check = true;
}
return check;
}
}