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

Java Problem : Write a program that allows users to input an integer for the siz

ID: 3843053 • Letter: J

Question

Java

Problem :

Write a program that allows users to input an integer for the size of an array. Randomly generate an integer for each element of the array. Next, create function to rotate the array . Rotation of the array means that each element is shifted right or left by one index, and the last element of the array is also moved to the first place.

For example:

            Enter the number of slots needs in the array: 8

            This is element of your array: 91 57 18 96 16 49 31 83

            Which direction to shift R/L : R

            How many times: 2

            This is element of your array: 31 83 91 57 18 96 16 49

For example:

            Enter the number of slots needs in the array: 3

            This is element of your array: 31 83 91

            Which direction to shift R/L : L

            How many times: 2

            This is element of your array: 91 31 83

Explanation / Answer

import java.util.Scanner; public class ShiftArrayValues { public static void main(String[] args) { int n; int[] array = new int[1000]; System.out.println("Enter number"); Scanner input = new Scanner(System.in); n = input.nextInt(); for (int i = 0; i
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