WRITTEN IN JAVA Write a function as follows:
Receive a string as a parameter.Count the length of the string.Count the occurrences of each distinguishable symbol in the string (use an array).Divide the factorial of the length by the product of the factorials of the occurrences.Return the quotient as the integer result.The point of this function is to find the result only by using the formulas for permutations.For example, BAAA the function counts that the string length is 4, that A occurs 3times, and that B occurs 1time, then divides 4!by 3!and 1!and returns the quotient, which is 4.
JAVA CODE: Main.java
import java.util.*;
public class Main
{
static int totalPermutations(String str)
{
int n=str.length();
int arr[]=new int[26];
for(int i=0;i<n;i++)
{
if(Character.isLowerCase(str.charAt(i)))
arr[str.charAt(i)-'a']++;
else if(Character.isUpperCase(str.charAt(i)))
arr[str.charAt(i)-'A']++;
}
int p=fact(n);
for(int i=0;i<26;i++)
p/=fact(arr[i]);
return p;
}
static int fact(int n)
{
if(n==1||n==0)
return 1;
return n*fact(n-1);
}
public static void main(String[] args) {
System.out.println("Total
Permutations of string BAAA = "+totalPermutations("BAAA"));
System.out.println("Total
Permutations of string CACB = "+totalPermutations("CACB"));
System.out.println("Total
Permutations of string abcccc =
"+totalPermutations("abcccc"));
}
}
Output:

WRITTEN IN JAVA Write a function as follows: Receive a string as a parameter.Count the length...
Write code in Java. In this step, functions and methods are synonymous. You may assume that strings only contain uppercase letters A through Z. 1. Write a function as follows: o Receive a string as a parameter. o Count the length of the string Count the occurrences of each distinguishable symbol in the string (use an array or map/dictionary). o Divide the factorial of the length by the product of the factorials of the occurrences. o Return the quotient as...
JAVA How do I write a code that receive a string, detect the length of each token with array, save the frequency of the length and print it? If the token length is longer than 10, the length is considered to be 0. If the frequency of the lengtg is 0 the information will not be printed ex) If the input is "Count the length of the token tokenlongerthanten" the output will be Length0 : 1 Length2 : 1 Length3...
Write a function getScores(...) that is given a string, an int type array to fill and the max number of elements in the array as parameters and returns an integer result. The function will find each substring of the given string separated by space characters and place it in the array. The function returns the number of integers extracted. For example: int values[3]; getScores("123 456 789", values, 3 ); would return the count of 3 and fill the array with...
Submit Chapter7.java with four (4) public static methods as follows: A. Write a method called mostCommon that accepts an array of integers as its only parameter, and returns the int that occurs most frequently. Break ties by returning the lower value For example, {1,2,2,3,4,4} would return 2 as the most common int. B. Write mostCommon (same as above) that accepts an array of doubles, and returns the double that occurs most frequently. Consider any double values that are within 0.1%...
Write a function SearchName() that takes the following three arguments: 1) A string pointer, 2) Length of the string array (int), 3) Name to search (string). The function then searches for the particular name in the string array and returns the index at which the name is found in the string array. Use a program to test the function.
Write MIPS code that converts a string containing a number into an actual number. The function to do this conversion, atoi (Array To Integer) should have a single input (the string) and output a single number (the integer). The Java/C code is as follows: atoi(a0: array) { int digit, number, i = 0; while( (array[i] >= '0') && (array[i] <= '9') ) { digit = array[i] - '0'; number = 10 * number + digit; i++; } return number; }
1. String Length Write a function that returns an integer and accepts a pointer to a C-string as an argument. The function should count the number of characters in the string and return that number. Demonstrate the function in a simple program that asks the user to input a string, passes it to the function, and then displays the function’s return value. c++
I have written this function in C++. A string of integers is passed in as dString and an integer is passed in as count. each dString integer is then indexed and passed into strTolnt integer array. each strTolnt integer is then passed through an equation and stored in temp array. I have printed each index in the array and the correct values are displayed, but when I print the entire array the value is displayed as hex. temp array is...
In java please
Write an efficient method that takes a string txt and an integer M as arguments and returns the position of the first occurrence of M consecutive blanks in the string. If there is no such occurrence it should return the length of txt (txt.length). Give a runtime analysis of the method. 4.
Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 5×6=6+6+6+6+6 2. Recursive findings Write a recursive boolean method named reFinding. The method should search an array for a specified value, and return true if the value is found in the array, or false if the value is not found in...