Question
Please help me to solve this code /** * Basic array problems for CS 170. * @author * @version */ public class PS14 { /**
Please help me to solve this code
/** * Basic array problems for CS 170. * @author * @version */ public class PS14 { /** * A. Write the method named midThree(). * * Given an array of ints, (of odd length), return a new * array length 3 containing the elements from the middle * of the array. The array length will be at least 3. * * Examples: * midThree({1, 2, 3, 4, 5}) returns {2, 3, 4} * midThree({8, 6, 7, 5, 3, 0, 9}) returns {7, 5, 3} * midThree({1, 2, 3}) returns {1, 2, 3} * * @param nums the original array to process. * @return a new array as specified above. */ // TODO - Write the midThree method here.
/** * Write the method named rotateLeft3(). * * Given an array of ints of length 3, return an array with * the elements "rotated left" so passing {1, 2, 3} returns * a new array containing {2, 3, 1} * * Examples: * rotateLeft3({1, 2, 3}) returns {2, 3, 1} * rotateLeft3({5, 11, 9}) returns {11, 9, 5} * rotateLeft3({7, 0, 0}) returns {0, 0, 7} * * @param nums the array to rotate. * @return a new, rotated array. Do not modify the original array. */ // TODO - Write the rotateLeft3 method here /** * Write the methods named makeLast(). * * Given an int array, return a new array with double the * length of the original where its last element is the same * as the original array, and all the other elements are 0. * The original array will be length 1 or more. * * Examples: * makeLast({4, 5, 6}) returns {0, 0, 0, 0, 0, 6} * makeLast({1, 2}) returns {0, 0, 0, 2} * makeLast({3}) returns {0, 3} * * @param nums the original array to process. * @return a new array as specified above. */ // TODO - Write the method makeLast here.
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started