Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a project called P8 and a cbu named P8 in a file called P8 Java. then fol

ID: 3681151 • Letter: C

Question

Create a project called P8 and a cbu named P8 in a file called P8 Java. then follow the instructions below exactly: 1. Write a method named createintegers that allocates. initializes. and returns an array of integers with the following entries 16, 21, 34, 49, 55, 60, 72, 83, 101 The method has no parameters and returns an array of 9 integers. 2. Write a method named create Doubles thai builds an array of floating point values that represent the squares of the numbers from 10.0 to 13.0. in steps of 0.5. inclusive of both boundaries The method has no parameters and returns an amy of doubles There are exactly 7 numbers in this array. 3. Write a method named create Strings that tales a String as an input parameter, and returns an array of string with 4 elements. The first element is the original string passed in. the second element is the same string converted to uppercase, the third element is the same strong converted to lowercase, and the fourth element is the same string with the first character removed. 4. Write a method named createChars that extracts the characters from a string and builds an array with them The method takes a parameter of type String and returns an array of characters. 5. Note:Each of the arrays must be allocated to be exactly the correct sire needed far the contents specified above 6. Write a method called sumArray that lakes an array of integers as a parameter, and returns an integer equal to the sum of all elements in the array. 7. Write a method called findLargest that takes an array of doubles as a parameter and returns a double equal to the largest element in the array. 8. Write a method called charFrequcncy that takes an array of strings and a single character as parameters The method should iletrate the array, counting instances of the character passed in. For example, if the array is ("Hello". "There")and we are asked to count the character 'c". the return value will be three If the character is not found in any of the elements in the array, the return v alue should be zero 9. Write a method called translateChars that takes an array of characters and returns an array of integers with the values that correspond to each element of the character array, For example, the character 'A' will be translated to 65. the character '0' will be translated to 48. and the character '%' will be translated to 37. The integer array returned should be of the same size as the array of characters passed in. 10. Add a main method with the usual signature that instantiates the P8 class and test its methods as follows: public static void Main(String[] args) {//Create arrays int[] integerArray = createIntegers(); System.out.printIn(Arrays.toString(integerArray)); double() doubleArray = createDoubles(); System.out.printIn (Arrays.toString(doubleArray)); String() stringArray = createStrings|"Hello There"); System.out.printIn(Arrays.toString(stringArray)); char() charArray = createChars("Java1234!6")); System.out.printIn(Arrays.toString(charArray));//Test processing Systen.out.println("Sum of integer array = " + sumArray(integerArray)); Systen.out.println("Largest of double array = " + findLargest(doubleArray)); System.out.println("Frequency of 'e'-" + charFrequency(stringArray. 'e')); System.out.println("Translated characters " + Arrays.toString(translateChars } Testing Based on the provided test code in the main method, you should see the following output if your methods are correct: [16, 21. 34, 49, 55, 40, 72, 83, 101) [100.0, 110.25, 121.0, 132.25, 144.0, 156.25, 169.0] (Hello There, HELLO THERE, hello there, ello There) (J, a, v, a, 1, 2, 3, 4, ;, 6) Sum of integer array = 491 Largest of double array = 169.0 Frequency of 'e' = 9 Translated characters = (74, 97, 118, 97, 49, 50, 51, 52, JJ, 11)

Explanation / Answer

/*********** P8.java ****************/

import java.util.Arrays;
import java.io.*;

public class P8 {

public static int[] createIntegers() {
int[] result = {16,21,34,49,55,60,72,83,101};
return result;
}

public static Double[] createDoubles() {
Double[] result = new Double[7];
int c = 0;
for (Double i = 10.0; i <= 13.0 ; i= i+0.5) {
result[c] = i*i;
c++;
}
return result;
}
  
public static String[] createStrings(String s) {
String[] result = new String[4];
result[0] = s;
result[1] = s.toUpperCase();
result[2] = s.toLowerCase();
result[3] = s.substring(0, 0) + s.substring(0 + 1);
return result;
}
  

public static char[] createCHars(String str) {
char[] result = str.toCharArray();
return result;
}


public static int sumArray(int[] result) {
int sum = 0;
for( int i : result) {
sum += i;
}
return sum;
}
  

public static Double findLargest(Double[] result) {
Double largetst = result[0];

for(int i=1; i< result.length; i++){
if(result[i] > largetst)
largetst = result[i];
}
return largetst;
}


public static int charFrequency(String[] result, char c) {
int count =0;
for(int i=0; i< result.length; i++){
String textValue = result[i];
for (int j = 0; j < textValue.length(); j++){
if (textValue.charAt(j) == (c)){
count++;
}
}
}
return count;
}

public static int[] translateChars(char[] result ) {
int[] arr = new int[result.length];
for(int i=0; i< result.length; i++){
arr[i] = result[i];   
}   
return arr;
}

  

public static void main(String[] args) {

   int[] integerArray = createIntegers();
System.out.println(Arrays.toString(integerArray));
Double[] doubleArray = createDoubles();
System.out.println(Arrays.toString(doubleArray));
String[] stringArray = createStrings("Hello There");
System.out.println(Arrays.toString(stringArray));
char[] charArray = createCHars("Java1234!&");
System.out.println(Arrays.toString(charArray));

System.out.println("Sum of integer array = " + sumArray(integerArray));
System.out.println("Largest of Double array = " + findLargest(doubleArray));
System.out.println("Frequency of 'e' = " + charFrequency(stringArray,'e'));
System.out.println("Translated characters = " + Arrays.toString(translateChars(charArray)));
  

}
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote