Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)
Java : Check String Is Singular or Plural | Java Programs
Latest :

Java : Check String Is Singular or Plural | Java Programs

Java Program to Check String being Singular or Plural – In this article, we will express the Java program to find out if any string is singular or plural. We will also include sample output and sufficient examples.

This code is for checking whether a given word is in plural form or not using Java language.

  • The problem here is to determine whether a user-defined input string is a plural word or not.
  • The constraint here is the inability to determine plurals that do not end with the alphabet s (example: sheep).
  • The input is a string provided by the user.
  • The output is a boolean value of true or false printed out which helps determine whether the input string is a plural word or not.

Output – 1:

  • Solution :
  1. In the main method, int variable count is initialized to 0 and a new Scanner class object is initialized and a reference variable sc is set to represent the object.
  2. This class is used to take user input in Java. Scanner class is part of the java.util package and hence the import statement, in the beginning, is stated to import the functionality of the specified class.
  3. The next line prints a statement to the console instructing the user to enter a string.
  4. The .nextLine() method is called by the Scanner object sc. This method reads a line of user input of a string value and stores it to the string variable name.
  5. Within the print statement in the last line, the checkPlural method is called and string name is passed in as the argument.
  6. The length of the parameter str representing the argument name  is stored in the int variable in the first line of this method.
  7. A conditional statement checks whether the last character in the given string (last character is at index n-1) is the character s.
  8. If this condition is satisfied, the method returns a boolean value of true which is then printed out to the console and a boolean value of false is returned and printed out.
  • Here, the input word is changes. The last alphabet is an and so the condition in the method checkPlural is satisfied.
  • The method returns a boolean value of true which is printed out.

Output – 2:

  • Here, the input word is change. The last alphabet is not an and so the condition in the method checkPlural is not satisfied.
  • The method returns a boolean value of false which is printed out.
x

Check Also

Java Right Arrow Star Pattern Program | Patterns

Java program to print Right Arrow star pattern program. We have written the below print/draw ...

atakoy escortatakoy escortbakırköy escortşişli escortbağcılar escortsightcaredeneme bonusu veren siteleristanbul, escortromabetdeneme bonusu veren sitelerdeneme bonusu veren sitelerDeneme Bonusu Veren SitelerDeneme Bonusu Veren SitelerDeneme Bonusu Veren SitelerDeneme Bonusu Veren Sitelerjustin tvdeneme bonusu veren sitelergrandpashabetgrandpashabetGrandpashabetsloticadeneme bonusu veren sitelerdeneme bonusu veren sitelercasibom girişonwinvaycasinobets10bahcesehir masaj salonucasibomdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelercasinofastDeneme bonusu veren sitelercasinofastdeneme bonusugrandpashabetdeneme bonusu veren sitelermarsbahis girişbetciotaraftariumdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerromabetistanbul escortgrandpashabetgrandpashabetgrandpashabetsekabetMeritkingcasibom girişmeritkinggrandpashabetroyalbetgrandpashabetdedebetcasibom girişcasibomcasibomcasibom girişcasibom girişpadişahbetbetciograndpashabetbetebetjojobet girişonwin girişjojobetroyalbetgrandpashabetholiganbetgrandpashabetimajbetmarsbahisholiganbetsekabetpusulabetpusulabet girişgrandpashabet girişholiganbetholiganbetroyalbetcasibomroyalbetcasibommeritkingcasibomcasibom girişcasibom girişcasibombetnanomegabahishacklink satın alsuperbetmeritking girişbetparkbetebet girişpusulabetasyabahis girişsuperbetinmeritking girişmeritking girişmeritkingholiganbetholiganbet girişsekabetsekabetodeonbetsuperbetgrandpashabetvaycasino girişvaycasino güncel girişvaycasinovaycasino girişvaycasino güncel girişcasibomcasibom girişcasibom güncel girişcasibomcasibom girişcasibom güncel girişgrandpashabetgrandpashabet girişgrandpashabetgrandpashabet girişsekabetasyabahisbetgray güncel girişjojobetgrandpashabetgrandpashabetgrandpashabetgrandpashabetgrandpashabetMeritkingzbahiscasibom girişcasibom girişcasibomdeneme bonusubets10imajbet girişmatbetpusulabetdeneme bonusu veren sitelerBetpas GirişvdcasinoDeneme Bonusu Veren Sitelerjojobetbahiscasinobahiscasino girişjojobetcasibombahiscasino girişCasibom güncel girişDinamobet güncel girişbahiscasinopusulabetHoliganbetzbahis girişkralbetmadridbet girişmadridbetotobet girişotobetkralbet girişkralbetmeritking토토사이트betzulabetzula girişadana escortkulisbetimajbet girişjojobetjojobetlotobetBetorder Girişcasibom güncel girişcasibomparibahisbetciocasibom girişcasibom girişcasibom girişücretsiz vpn indirmeritkingkalebetkalebet girişcasibom güncel girişBetpuancasibom