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
How does the zone theory of optical systems resolve the apparent incompatibility of trichromacy and opponency?
lara [203]

Answer:

Money money money

Explanation:

4 0
3 years ago
Which of the following are safety guidelines when socializing online?
DochEvi [55]

Answer:

All of them execpt five and three.

Explanation:

It is okay to have social media and receive messages.

3 0
2 years ago
Which statement describes what happens when a user configures No Automatic Filtering in Junk Mail Options?
NeTakaya

Answer: Most obvious spam messages will still reach the client computer

Explanation:

It should be noted that by default, usually the junk email filter is already set to No Automatic Filtering.

When a user configures No Automatic Filtering in Junk Mail Options, it should be noted that most obvious spam messages will still reach the client computer.

Therefore, the correct option is D.

5 0
3 years ago
question 7 packages installed in rstudio are called from cran. cran is an online archive with r packages and other r-related res
Ksenya-84 [330]

Packages installed in rstudio are called from cran. cran is an online archive with r packages and other r-related resources, is the true statement.

<h3>What are CRAN packages in R?</h3>

It comprises archives for both the most recent and prior versions of the R distribution, donated R packages, and documentation. It provides both source packages and pre-compiled binaries for Windows and macOS. there are more than 16,000 bundles available.

The version of R that is made available through CRAN is compatible with the integrated development environment for R, referred to as RStudio. All of the major systems support RStudio, which includes a variety of tools that boost productivity.

Thus, it is the true statement.

For more information about CRAN packages in R, click here:

brainly.com/question/10658169

#SPJ1

7 0
1 year ago
What will be the output of the following query on the table below?
shtirl [24]

Answer:

b

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • In a word processing program, the ribbon or menus contain the
    12·1 answer
  • Solar power plants trap the sun’s energy and convert it into electricity. What is a problem associated with this technology?
    11·1 answer
  • A looping construct that continues to repeat until the expression becomes false is
    5·2 answers
  • Which of the following instruments are used when performing a high-rate discharge test on a storage battery
    7·1 answer
  • Which of the following statements is true?
    13·1 answer
  • What was the process called that required the photographer to have a tent or darkroom handy so that chemicals could be mixed qui
    7·1 answer
  • write a pay-raise program that requests a person's first name, last name, and current annual salary, and then displays the perso
    6·1 answer
  • Write a Python program segment, using a loop, to calculate and print the sum of the odd integers from 20 to 120. (Hint: 21 23 25
    13·1 answer
  • The _____ component of a decision support system (DSS) includes mathematical and statistical models that, along with the databas
    14·1 answer
  • Wilma is looking for facts about social media for her research project. What fact should she use for her project?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!