Since no language is specified in the question Iam going to us python3 language
Cases considered:
Input : 2 sentences
Output:Number of letters common in both sentences
Therefore what i did is converting all the letters in both the sentences to lower case and chect whether the letters are present in both the sentences checking from a to z and returning tje count value
In my program the user can give the inputs for 2 sentences
Program:
def countCommon(sentence1,sentence2):
test="abcdefghijklmnopqrstuvwxyz"
sentence1.lower()
sentence2.lower()
count=int(0)
for i in test:
if((i in sentence1)&(i in
sentence2)):
count+=1
return count
sentence1=input()
sentence2=input()
print(countCommon(sentence1,sentence2))
Q4. Write a method called countCommon that takes 2 sentences and returns the number of letters...
Write a public static method named getMaxOf2Ints that takes in 2 int arguments and returns the Maximum of the 2 values Write a public static method named getMinOf2Ints that takes in 2 int arguments and returns the Minimum of the 2 values Write apublic static method named getMaxOf3Ints that takes in 3 int arguments and returns the Maximum of the 3 values Write a public static method named getMedianOf3Ints that takes in 3 int arguments and returns the Median Value...
JAVA Array 3. Write a method called noVowels that takes a String as input and returns true if it doesn't contain any vowels (a, e, i, o, u)
Write a cell method that takes a single double as an argument and returns an int. The int should be the next highest whole integer (eg 3.14 would return 4). Use math not built-in Java methods mins) Write a method that takes a string as an argument. It your string is more than 10 letters or less than 1 letter return "Bad number". Otherwise, return the telephone number equivalent of the input. Your return can be of type String Eg...
Write a Java method called compare that takes two integers as input parameters and returns 1 if the first parameter is larger than the second parameter returns – 1 if the second parameter is larger than the first parameter, and returns 0 if the two parameters are equal.
Write a ceil method that takes a single double as an argument and returns an int. The int should be the next highest whole integer (eg 3.14 would return 4). Use math, not built-in Java methods (est. 20 mins) Write a method that takes a string as an argument. If your string is more than 10 letters or less than 1 letter return "Bad number." Otherwise, return the telephone number equivalent of the input. Your return can be of type...
Write a function called most_consonants(words) that takes a list of strings called words and returns the string in the list with the most consonants (i.e., the most letters that are not vowels). You may assume that the strings only contain lowercase letters. For example: >>> most_consonants(['python', 'is', 'such', 'fun']) result: 'python' >>> most_consonants(['oooooooh', 'i', 'see', 'now']) result: 'now' The function that you write must use a helper function (either the num_vowels function from lecture, or a similar function that you...
2. Write a LISP function COUNTLETS which takes a list and returns the number of top-level alphabetic atoms in the list. For example: COUNTLETS ( (A 2) B 3 C4 (D 5))) Returns the value 2, the letters A and D are not at the top level
Python 3: Write a function called every_other_character() that takes in a string and returns a new string with every other character removed. That is, the new string will include the first, third, fifth, etc. letters of the given string. Must use a while or for loop in the solution.
write an algorithm function called balance() in javascript that takes in a string and returns a strinf with balanced parantheses only. the string should be able to contain only parantheses, numbers, and letters. include comments of each portion of your code balance(“()()”) should return “()()” balance(“())”) should return “()” balance(“a(b)c”) should return “a(b)c” balance(“a(b)c())”) should return “a(b)c()”
I am trying to write a java method that takes two string parameters from a user and then returns the first input after removing the letters that appear in the second input. For example: if input1 = fortune and input2 = tune then the method returns "for" seems simple but I am not understanding exactly how to tackle this thanks!!