. Given a string of at least 3 characters as input, if the length of the string is odd return the character in the middle as a string. If the string is even return the two characters at the midpoint. public class Class1 { public static String midString(String str) { //Enter code here } } ----------- 2. Given an array of integers return the sum of the values stored in the first and last index of the array. The array will have at least 2 elements in it
1. Given a string of at least 3 characters as input, if the length of the string is odd return the character in the middle as a string. If the string is even return the two characters at the midpoint.
public class Class1 {
public static String midString(String str) {
//Enter code here
}
}
-----------
2. Given an array of integers return the sum of the values stored in the first and last index of the array. The array will have at least 2 elements in it
public class Class1 {
public static int endSum(int[] values) {
//Enter code here
}
}
-----------
3. The method takes a string as a parameter. The method prints treat if the string is candy or chocolate (of any case, such as CaNdY) Otherwise print trick
import java.util.Scanner;
public class Class1 {
public static void trickOrTreat(String str) {
//Enter code here
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
trickOrTreat(s.nextLine());
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps