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

Please separate answer for 1, 2, and 3 there should be different answer because

ID: 3606729 • Letter: P

Question

Please separate answer for 1, 2, and 3 there should be different answer because they are different questions.

1. Write a Java method with a one-character parameter that returns the parameter shifted one letter to the right ('A' becomes 'B', 'B' becomes 'C', etc.) if it is a capital letter; otherwise it returns the original parameter value.

2. Write a Java method that has a single parameter for an array of doubles and returns another array of doubles with the same length and has each element divided by 2.0.

3. Write a Java method that will search the array d for the value in the variable t. Use d and t as parameters. If the value of t is not found, the method returns -1. If the value of t is found, the method returns the first value of the subscript, sub, such that d[sub] has the same value as t. Data types:

char [] d; int sub; char t;

Explanation / Answer

Question1:

Here is code:

public class Shifting {

public static void main(String a[]) {
char c = 'A';
char result = shift(c);
System.out.println("Result is :" + result);
}

private static char shift(char c) {
if (c >= 'A' && c <= 'Z') {
return (char)((int)c + 1);
}
else{
return c;
}
}

}

Output:

Result is :B

Question2:

Here is code:

public class Dividing {

public static void main(String a[]) {
double[] myList = {1.9, 2.9, 3.4, 3.5};
double[] result = dividing(myList);
System.out.print("Result is :");
for (int i = 0; i < result.length; i++) {
System.out.print(result[i] + " ");
}
}

private static double[] dividing(double[] myList) {
double[] d = new double[myList.length];
for (int i = 0; i < myList.length; i++) {
d[i] = myList[i] / 2.0;
}
return d;
}
}

Output:

Result is :0.95 1.45 1.7 1.75

Question3:

Here is code:

public class Finding {

public static void main(String a[]) {
char[] myList = {'a', 'b', 'c', 'd', 'e'};
char t = 'b';
int sub = find(myList, t);
if (sub == -1) {
System.out.println("character not found");
} else {
System.out.println("character found at " + sub + " index");
}
}

private static int find(char[] d, char t) {
for (int i = 0; i < d.length; i++) {
if (d[i] == t) {
return i;
}
}
return -1;
}
}

Output:

character found at 1 index

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