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
Explain why interrupt times and dispatch delays must be limited to a hard real-time system?
BigorU [14]

Answer:

The important problem is explained in the next section of clarification.

Explanation:

The longer it is required for a computing device interrupt to have been performed when it is created, is determined as Interrupt latency.

The accompanying duties include interrupt transmission delay or latency are provided below:

  • Store the instructions now being executed.
  • Detect the kind of interruption.
  • Just save the present process status as well as activate an appropriate keep interrupting qualitative functions.
7 0
2 years ago
Every workplace should have an emergency plan of action.
pochemuha

Answer:

yes i agree with that the answer is in fact true

Explanation:

follow my in sta gram at grac.ehihi

6 0
2 years ago
Read 2 more answers
Andy wants to touch up his holiday photographs because they appear too bright and the color is washed out. Which software applic
Veronika [31]
The application andy wants to use is adobe photoshop 
5 0
2 years ago
Question 1 of 19
shusha [124]

Answer:

UI Character Presets

Explanation:

User Interface is an option or go-to menu in a desktop application. For example, Photoshop. It allows a user to tweak the outlook to his or her own preference rather than the default settings.

To do this, a user is often tasked to do the following:

1. Click on the "Edit" menu

2. Navigate and click on "Preferences"

3. Select the "Interface" link

The options available to change includes:

a. UI Scaling

b. UI Font Size

c. UI Language.

Hence, in this case, the element that is not a selection in the Interface preferences is "UI Character preset"

7 0
3 years ago
For your biology class, you have taken a number of measurements for A plant growth experiment. you wish to create a chart that s
Natasha2012 [34]
The answer is B, calc or excel
4 0
2 years ago
Other questions:
  • Java - Given a String variable response that has already been declared, write some code that repeatedly reads a value from stand
    12·1 answer
  • GAMES Which is better Roblox or BattleCamp Basically Free Points But Please Answer
    7·2 answers
  • #Write a function called "replace_all" that accepts three #arguments: # # - target_string, a string in which to search. # - find
    11·1 answer
  • Create a program that simulates a race between several vehicles. Design and implement an inheritance hierarchy that includes Veh
    11·1 answer
  • The Uniform Electronic Transmission Act (UETA) a. declares that e-signatures are invalid. b. has only been adopted in a handful
    8·1 answer
  • Please help with coding assignment.
    11·1 answer
  • You have imported a library with the birthMonth() function. Based on the API, how many strings are inputed to calculate the birt
    11·1 answer
  • Five uses of the operating system​
    10·2 answers
  • Write a pseudocode algorithm that prompts the user to enter a three-digit number and outputs the hundreds, tens and units.
    6·1 answer
  • Which of these is a possible disadvantage of working with a team?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!