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
Aleksandr [31]
3 years ago
11

Write a program with a main method that asks the user to enter an array of 10 integers. Your main method then calls each of the

three methods described below and prints out the results of the two methods which return values (see format below).
Computers and Technology
1 answer:
Kay [80]3 years ago
8 0

Answer:

The remaining part of the question is given as follows:

printReverse - a void method that reverses the elements of the array and prints out all the elements in one line separated by commas (see sample output below).

getLargest - an int method that returns the largest value in the array.

computeTwice- a method that returns an array of int which contains 2 times of all the numbers in the array (see the sample output below).

Explanation:

// Scanner class is imported to allow the program receive

// user input

import java.util.Scanner;

// Arrays class is imported to allow the program display the array

// in a pretty way

import java.util.Arrays;

//The class definition

public class Solution {

   // main method is defined which signify beginning of program

  // execution

   public static void main(String[ ] args) {

       // an array is initialized with a size of 10

       int[] array =new int[10];

       // Scanner object scan is defined

       Scanner scan =new Scanner(System.in);

       // A loop is initiated to receive 10 user input to fill the array

       for(int i=0; i < 10; i++){

           System.out.print("Please enter number: ");

           array[i]=scan.nextInt();

       }

       

       // A blank line is print

       System.out.println();

       // printReverse method is called with the received array as

      // argument

       printReverse(array);

       // A blank line is print

       System.out.println();

       // The largest number is printed

       System.out.println("The largest number is: " + getLargest(array));

       // computeTwice method is called to display the array after

      // multiplying each element by 2

       computeTwice(array);

       System.out.println( "The values of the computed twice array is: " );

       // Arrays class is used to print the array in form of a string

      // not object

       System.out.println(Arrays.toString(array));

   }

   

   //printReverse method declared with inputArray as parameter.

   // It has no return type

   public static void printReverse(int[] inputArray){

       System.out.print("Here is the arrray in reverse order: ");

       // A loop goes through the array starting from the end

       // and display each element

       for(int i = (inputArray.length - 1); i >= 0; i--){

           if(i == 0){

               // If the last element, do not append comma

               System.out.print(inputArray[i]);

           } else {

               // If not the last element, do append a comma

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

           }

       }

   }

   

   // getLargest method is declared with inputArray as parameter

   //  it compare each element in the array and return the largest

   public static int getLargest(int[] inputArray){

       // The first element is assumed to be the largest before the

      // loop begin

       int max = inputArray[0];

       for(int i = 1; i < inputArray.length; i++){

           if (inputArray[i] > max){

               max = inputArray[i];

           }

       }

       return max;

   }

   

   // computeTwice is declared with inputArray as parameter

   // it loop through the array and multiply each element by 2

   // it then return a modified array

   public static int[] computeTwice(int[] inputArray){

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

           inputArray[i] *= 2;

       }

       return inputArray;

   }

}

You might be interested in
Write a program using LinkedList class and ListIterator interface to demonstrate the following activities:
babunello [35]

The program is an illustration of LinkedList.

<h3>What is a LinkedList?</h3>

A LinkedList is a data structure element that contains nodes where each node represents a value and also points to the next node.

<h3>The main program</h3>

The program written in Java, where comments are used to explain each line of the program is as follows:

import java.util.LinkedList;

import java.util.Iterator;

class Main {

 public static void main(String[] args) {

     //This creates the Alphabets LinkedList

   LinkedList<String> Alphabets = new LinkedList<String>();

   //This creates an iterator for the Alphabets LinkedList

   Iterator it = Alphabets.iterator();

   //This adds P, Q, R and T to the list

   Alphabets.add("P");    Alphabets.add("Q");    Alphabets.add("R");    Alphabets.add("T");

   //This prints the Alphabets LinkedList

   System.out.println(Alphabets);

   //This adds O to the beginning of the list

   Alphabets.addFirst("O");

   //This prints the Alphabets LinkedList

   System.out.println(Alphabets);

   //This adds U to the list

   Alphabets.add("U");

   //This prints the Alphabets LinkedList

   System.out.println(Alphabets);

   //This adds S after R

   Alphabets.add(4,"S");

   //This prints the Alphabets LinkedList

   System.out.println(Alphabets);

   //This removes O and Q from the list

   Alphabets.remove("O"); Alphabets.add("Q");

   //This prints the Alphabets LinkedList

   System.out.println(Alphabets);

 }

}

Read more about LinkedList at:

brainly.com/question/19754898

3 0
2 years ago
3. What are the first steps that you should take if you are unable to get onto the Internet? (1 point)
slavikrds [6]

Answer:

Check your router connections then restart your router.

Explanation:

When the internet connection is not displaying properly then the first step is to check the router. The network icon on the internet displays the availability of internet. Adjust the router and see if the router is working properly. If not restart the router so that it adjusts its settings to default. The connection will be available on the computer and internet will start working normally.

3 0
3 years ago
A _____ is the viewing area for a web page, which is much smaller on a phone than on a traditional desktop.
-BARSIC- [3]
A viewport is the viewing area for a web page, which is much smaller on a phone than on a traditional desktop .
6 0
2 years ago
In which program structure does the processor verify the mentioned condition only after executing the dependent statements once?
Cloud [144]
B. because you have to do it while in structure.
3 0
3 years ago
Read 2 more answers
Many mobile devices can perform Internet searches and other tasks via
Sedaia [141]

the answer is D Voice commands

8 0
3 years ago
Other questions:
  • When you append a(n) ____ to a command, the command is run in a background process?
    8·1 answer
  • Which component is the smallest unit in a spreadsheet?
    14·2 answers
  • Help me out here pleaseeeee
    9·2 answers
  • Microsoft's
    8·1 answer
  • Your bluetooth headset is waiting for another bluetooth device to locate its signal. what is this mode known as?'
    8·1 answer
  • dam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took to get the correct
    9·1 answer
  • Write a programme with C++ language wich print the biggest number in between three numbers , whith INT
    14·1 answer
  • Using a text editor, create a file that contains a list of at least 15 six-digit account numbers. Read in each account number an
    7·1 answer
  • HW2.24. Statement: Area of a Triangle The area of a triangle can be computed by knowing the base and height of the triangle usin
    11·1 answer
  • You can resize a row in a table by dragging the ____.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!