Question: Modify the method you wrote in question 10 so it performs a caseinsensitive test. The method should return true if the argument ends with .com
Modify the method you wrote in question 10 so it performs a caseinsensitive test. The method should return true if the argument ends with .com in any possible combination of uppercase and lowercase letters.
method that i wrote for 10
public class methodIJustWrote { public static boolean DotCom(String input) { if (input.endsWith(".com")) { return true; } return false; }
public static void main(String[] args) { //Create a string object and initialize its value. String str = "Rachel12Green@live.com"; //If the value returned by the call to the function //endsWithDotCom() by passing the input string is //true, then display an appropriate message showing //that string ends with .com. if(DotCom(str)) { System.out.println("String " + str + " ends with \".com\"!"); } //Otherwise, display an appropriate message showing //that string doesn't end with .com. else { System.out.println("String " + str + " does not end with \".com\"!"); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
