JAVA Create a class named TextProcessing which has the following methods— (1) ge
ID: 3682576 • Letter: J
Question
JAVA
Create a class named TextProcessing which has the following methods— (1) getWordsNumber(): this method accepts a string (few sentences long) as an argument and returns the number of words it contains. (2) getVowelsNumber(): this method accepts a string (few sentences long) as an argument and returns the number of vowels it contains. (3) displayBackwardString(): this method accepts a string (few sentences long) as an argument and displays its contents backward. (4) isValid(String password): this method accepts a password as an argument and verifies whether the password meets the following criteria: I. The password should be at least eight characters long. II. The password should contain at least one uppercase and at least one lowercase letter. III. The password should have at least one digit. If the password meets the above criteria, the method isValid() returns true. Otherwise, it returns false. Then write a demo class to work with TextProcessing class.
Explanation / Answer
import java.util.*;
public class TextProcessing
{
{
Scanner in=new Scanner(System.in);
public string demo(Scanner in)
{
String input;
input=in.nextline();
If(input.legth()>0)
{
demo(input);
}
Else
System.out.println(“Error…Reneter String”);
input=in.nextLine();
}
return input;
}
public void getVowelsNumber(String input)
{
int count=0;
for(int i=0; i< input.legth();i++)
char ch=input.charAt(i);
If (ch==’a’ ||ch==’e’ ||ch==’i’ || ch==’o’ ||ch==’u’||
ch==’A’ ||ch==’E’ ||ch==’I’ || ch==’O’ ||ch==’U’)
{
count++;
}
}
System.out.println(“Number of vowels: “ + count);
}
}
public void displayBackwardString(String input)
{
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.