65 666
Assignments Done
99,2%
Successfully Done
In October 2018

Answer to Question #18462 in Java | JSP | JSF for Sayed Abdullah Almousawi

Question #18462
Write a void method Shift that takes three parameters A, p, d.
A is an array, p is the number of positions and d is the direction (L = left, R = right). The method should shift the contents of A p positions in the d direction.
(B) To test your method, write a program that reads an array of 10 elements then calls Shift twice and prints the array after each call.
Example:
Enter 10 elements of array A:
17 11 12 15 18 19 20 23 28 39
Enter Shift direct L
Enter number of positions 3
Array After Shift 15 18 19 20 23 28 39 0 0 0
Enter Shift direct R
Enter number of positions 2
Array After Shift 0 0 15 18 19 20 23 28 39 0
====================================================
Bonus: Change the program to do Array rotation rather than shifting.
For Example:
Enter 10 elements of array A:
17 11 12 15 18 19 20 23 28 39
Enter Rotate direct L
Enter number of positions 3
Array After Rotation 15 18 19 20 23 28 39 17 11 12
Enter Rotate direct R
Enter number of positions 2
Array After Rotation 11 12 15 18
Expert's answer

Not answered

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions