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
A ___ is an organized collection of data in digital format that helps users to keep
inn [45]

Answer:

database is the correct answer

Explanation:

5 0
3 years ago
Explain why testing can only detect the presence of errors, not their absence.
Alchen [17]

Explanation: Testing is a set of activities that aim to detect software anomalies in a way that the errors can be discovered and correctes. The goal of software testing is to observe if the software behavior meet the requirements that they are expected to meet. Testing demonstrates to the developer that the software fullfils its requirements and it is a way to find out if it behaves in a incorrect, undesirable ou different form from the specifications.

6 0
3 years ago
Explain different users of computer in briefly?​
goldfiish [28.3K]

Answer:

The question is invalid; there are many types of computer user. Why on earth do you think there are five?

From the top of my head.

Casual- someone at home browsing the web, reading email.

IT Consultant. Advising people.

Software developer- writing software

Secretary - manages email for a company

Academic. Writing research papers.

Monitors. Monitor a computer system.

That’s six off the top of my head. There are probably a dozen more. So why do you think there are five?

3 0
2 years ago
A client contacted you to request your help in researching and supplying the hardware necessary to implement a SOHO solution at
Tcecarenko [31]

Answer:

Option 2 i.e., DHCP server.

Explanation:

A client approached the user to ask about their support towards investigating as well as providing necessary equipment required for implementing a SOHO system for his latest house corporation.  

So, the following SOHO router functionality facilitates the installation of IP addresses both for the cable and wireless networks on the private server.

7 0
3 years ago
As a bank employee, you often work from home and remotely access a file server on the bank’s network to correct errors in financ
strojnjashka [21]

Answer:

TACACS+

Explanation:

Terminal Access Controller Access-Control System Plus (TACACS+) is a protocol that provides detailed accounting information and flexible administrative control over the authentication, authorization, and accounting process.

3 0
3 years ago
Other questions:
  • Fill in the blank
    11·1 answer
  • which of these describe raw data?check all of the boxes that apply A) what a person buys B) where a person lives C) data that ha
    9·1 answer
  • A process that rearranges the data and objects in a database to decrease its file size, thereby making more space available on y
    11·1 answer
  • Join zoom meet <br>id=547 458 9345<br>pw=sencHURI​
    8·2 answers
  • Can someone solve this for me please? It’s part of an escape room.
    13·2 answers
  • Pleasee help. How do you fix this problem in discord?
    10·1 answer
  • Suppose the ESPN website uses 8-bit unsigned integers to store how many points a team has scored in
    12·1 answer
  • Please could you help me
    6·2 answers
  • What is a trusted computing base (TCB)? Hosts on your network that support secure transmissions The operating system kernel and
    9·1 answer
  • Computer always produces wrong output true or false<br>​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!