1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kobusy [5.1K]
3 years ago
14

Write a program that prompts the user for an integer, then asks the user to enter that many values. Store these values in an arr

ay and print the array. Then reverse the array elements so that the first element becomes the last element, the second element becomes the second to last element, and so on, with the old last element now first. Do not just reverse the order in which they are printed; actually change the way they are stored in the array. Do not create a second array; just rearrange the elements within the array you have.
Computers and Technology
1 answer:
Svetllana [295]3 years ago
3 0

Answer:

//The Scanner class is imported to allow the program receive user input

import java.util.Scanner;

//The class Solution is defined

public class Solution {

   //The main method is defined here and signify the beginning of program execution

   public static void main(String args[]) {

       

       //Scanner object 'scan' is created to receive user input

       Scanner scan = new Scanner(System.in);

       //Prompt display to the user to enter size of array

       System.out.print("Enter the range of array: ");

       //User input is assigned to arraySize

       int arraySize = scan.nextInt();

       //userArray is initialized with arraySize as its size

       int[] userArray = new int[arraySize];

       

       //counter to count number of array element

       int count = 0;

       //while loop which continue executing till the user finish entering the array element

       while (count < arraySize){

           System.out.print("Enter each element of the array: ");

           userArray[count] = scan.nextInt();

           count++;

       }

       

       //A blank line is printed for clarity

       System.out.println();

       

       //for loop to print each element of the array on straight line

       for(int i =0; i <userArray.length; i++){

           System.out.print(userArray[i] + " ");

       }

       

       //A blank line is printed for clarity

       System.out.println();

       

       //for loop is use to reverse the array in-place

       for(int i=0; i<userArray.length/2; i++){

           int temp = userArray[i];

           userArray[i] = userArray[userArray.length -i -1];

           userArray[userArray.length -i -1] = temp;

       }

       

       //for loop to print each element of the reversed array on straight line

       for(int i =0; i <userArray.length; i++){

           System.out.print(userArray[i] + " ");

       }

     

   }

}

Explanation:

The program is commented to give detailed explanation.

The for-loop use in reversing the array works by first dividing the array into two half and exchanging the first half elements with the second half elements. The element from the first half is assigned to temp variable on each loop, then the element is replaced with the equivalent element from the second half. And the element from the second half is replaced with the value of temp.

You might be interested in
Brief description email etiquette​
Solnce55 [7]

Answer: See explanation

Explanation:

Email etiquette is defined as the code of conduct which helps to guide the behavior when people send or respond to emails. Some of ail etiquette include:

• Using proper and correct grammar and punctuations.

• Replying quickly too emails.

• Including a clear and direct subject.

• Proofreading of messages.

• Cautious with humour.

• Sending of smaller files and compressing large files.

7 0
3 years ago
Once you fix the bug in a code, what is the last thing you should do?
aleksklad [387]

Answer:

Know what the code should do

4 0
3 years ago
Which of the following methods is the easiest way to set up a VPN client on a computer for a user who is not technical?
Pie

Answer:

Option D.

Use CMAK to create an executable to install.

Explanation:

The CMAK is the Connection Manager Administration Kit it is a feature in Microsoft Windows that allows users to customize the remote connection experience for users on their network.

The CMAK can be simply used by the technical expert to remotely operate the client computer, and customize the VPN himself without the non-technical user having to do anything. This can be done for computers only on a network however.

3 0
3 years ago
Which section of a cover letter would include your skills education and work experience
trasher [3.6K]
Resume. I do believe
8 0
3 years ago
Read 2 more answers
How to set up a simple peer-to-peer network using a star topology?
kkurt [141]

Answer:

The description including its scenario is listed throughout the explanation section below.

Explanation:

Star topology seems to be a LAN system under which all points are connected to a single cable link location, such as with a switch as well as a hub. Put it another way, Star topology is among the most commonly used network configurations.

Throughout this configuration or setup:

  • Each common network setups network unit, such as a firewall, switch, as well as computer.
  • The main network computer serves as either a server as well as the peripheral system serves as just a client.
7 0
3 years ago
Other questions:
  • A school librarian has been asked to identify inappropriate Internet usage. Which students would most likely be reported to the
    5·2 answers
  • What was the first<br> 1:search engine<br> 2:website<br> 3:time the internet started
    6·1 answer
  • Which protocol do many browsers assume when you enter a URL in the address field?
    9·1 answer
  • PLEASE HELP THIS IS MY LAST CHANCE TO PASS MY QUIZ
    13·2 answers
  • *When a computer programmer is finished writing or developing a program, what has to happen first before the computer can unders
    8·1 answer
  • Use the drop-down menus to match each description to its corresponding term.
    7·1 answer
  • A higher resolution image will mean a?
    13·2 answers
  • Write a pseudocode algorithm to ask the user to input the name of a student, the marks he/she received in a test and the worth o
    10·1 answer
  • Which insert image option allows a user to insert images from the internet?
    5·2 answers
  • How to add up multiple user inputs for example: If i ask the user How many numbers do you want to add? they say 5 then i out put
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!