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
When the user types into a Textbox control, the text is stored in the control's __________ property.
joja [24]

The property that stores the text a user types into a Textbox is called the: control's text property.

<h3>The Textbox Control</h3>

The Textbox Control is employed in display a text or accept the text as an input from a user. Also, single line of text can be accepted as input at runtime from a VB.NET Windows.

The text that displays on the Textbox can also be set. The control's text property therefore stores the text a user types into Textbox.

In conclusion, the property that stores the text a user types into a Textbox is called the: control's text property.

Learn more about Textbox Control on:

brainly.com/question/5677552

3 0
2 years ago
Design a program that asks the user to enter a string containing a series of single digit numbers with nothing separating them.
ruslelena [56]

Answer:

  1. def calcSum(d):
  2.    sum = 0
  3.    for x in d:
  4.        sum += int(x)
  5.    return sum
  6. digits = input("Please enter your digits: ")
  7. print(calcSum(digits))

Explanation:

The solution code is written in Python.

Firstly, create a function that take one input digit string (Line 1).

In the function, create a sum variable with initial value 0.

Use a for loop to traverse through each character in the digit string and in the loop use int method to convert each character to integer and add it to sum variable (Line 3-5) and return the sum as output.

Next, use input function to prompt user enter a digit string (Line 7).

Lastly test the function by passing the input digit as argument and print the result (Line 8).

7 0
3 years ago
How does toothbrushes affect the world of technology?
Yuri [45]

Answer:

The invention of the toothbrush made a huge impact of society and people for many reasons. You should always brush your teeth and keep your mouth clean so you will have nice, white teeth, healthy gums, good breath, and just a clean mouth! Without the toothbrush, your mouth would be smelly, gross, and full of bacteria.Some of the different impact categories included acidification, climate change, eutrophication, human health, land use, resource use and water scarcity. The results concluded that the electric toothbrush had the greatest environmental impact in 15 out of the 16 categories with water scarcity being the exception.Using the electric toothbrush as an example, this article examines the growing acceptability of domestic health technologies that blur the traditional boundaries between health, aesthetics and consumption. By using empirical material from individual and household interviews about people's oral health practices, this research explores the relationships between an everyday artefact, its users and their environments. It investigates the ways in which oral health technologies do, or do not, become domesticated in the home environment. We conclude that the domestication of oral health technologies is not inevitable, with the electric toothbrush often becoming an ‘unstable object' in the domestic setting.

Explanation:

3 0
2 years ago
Read 2 more answers
Good keyboarding technique includes ________
Svetlanka [38]

Answer:

Keeping you hands on the homerow keys

Explanation:

3 0
2 years ago
Read 2 more answers
The set of coordinating colors applied to backgrounds, objects, and text in a presentation is called:
Sonja [21]

Answer:

theme colors

Explanation:

As said, a group of colors that are used to format text and objects in a document. When you open the Color menu, these colors determine what you see.

3 0
2 years ago
Other questions:
  • Which of these is a typographical clue?
    9·2 answers
  • Which of the following STEM discoverers developed a new type of computer hardware?
    11·1 answer
  • What is an identifier? Give an example of an identifier.
    13·1 answer
  • Which of the following is not something that consumers need to pay attention to order to make rational choices
    6·2 answers
  • Writе thе dеclaration of a doublе pointеr namеd avеragе
    10·1 answer
  • Someone please help will mark as brainliest
    8·2 answers
  • 100POINTS!!!!!!!!!!!!!!!!!!!I WILL ANSWER ALL OF YOUR QUESTIONS PLEASE LOVES:)))Upload your completed project including the foll
    12·1 answer
  • Complete the sentence.<br> Python is a_____<br> level language compared to bytecode.
    7·2 answers
  • How long does an online snap application take to process ohio
    6·1 answer
  • . Imagine that you were programming without an IDE. What problems might you encounter?​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!