Hi I need some help on this problem. Please help, ill rate alifesaver no matter
ID: 3617654 • Letter: H
Question
Hi I need some help on this problem. Please help, ill rate alifesaver no matter what. I started it a bit as you can see on thebottom, but dont know what else to do. Thanks again.
Write a program that prompts the user for an integer, then asksthe user to enter that many values. Store these values in an arrayand print the array. Then reverse the array elements so that thefirst element becomes the last element, the second element becomesthe second to last element, and so on, with the old last elementnow first. Do not just reverse the order in which they are printed;actually change the way they are stored in the array. Do not createa second array; just rearrange the elements within the array youhave. (Hint: Swap elements that need to change places.) When theelements have been reversed, print the array again.
Reversing array
Input :5301982
Output : 2891035
Int temp k[6] ;
K[6]=k[0] ;
K[0]=temp;
i-1/2
int temp = k[i];
k[i] = k[k.length-(i+1)]
k[k.length-(i+1)=temp
Explanation / Answer
please rate - thanks import java.util.*; public class reversearray {public static void main(String[] args) { Scanner input = new Scanner(System.in); int k,temp,n; System.out.print("How many numbers do you have? "); n=input.nextInt(); int [] a =new int[n]; for(k=0;kRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.