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
Help please will mark BRAINLIEST
aliya0001 [1]
Origin symmetry, I believe it’s conceptual or artistic but i’m not 100% sure, also not 100% on this one but I think it’s false, the first one, third one. Like I said I don’t know much about blender but I think the others are correct.
3 0
3 years ago
The following loop is intended to print the numbers 1, 2, 3, 4, 5.
balu736 [363]

Answer:

range

Explanation:

range(num1, num2) returns the numbers from num1 up to but not including num2.

Example: range(1, 4) will return the numbers 1, 2, 3.

Hope this helps :)

8 0
3 years ago
Multiple Select
s344n2d4d5 [400]

Since you wrote a program to compare the portion of drivers who were on the phone. The statements are true are option  2, 3, 4 and 5:

2. You could modify the program to allow the user to enter the data.

3. A different set of observations might result in a larger portion of male drivers being on the phone.

4. Even when confident that the mathematical calculations are correct, you still need to be careful about how you interpret the results.

5. It is important to test your program with a small enough set of data that you can know what the result should be.

<h3>What use does a driver program serve?</h3>

A computer software known as a driver, sometimes known as a device driver, that serves as a bridge between the operating system and a device such a disk drive, or keyboard. The device's collection of specific commands must be thoroughly understood by the driver.

In software, a driver offers a programming interface for managing and controlling particular lower-level interfaces that are frequently connected to a particular kind of hardware or other low-level service.

Therefore,  based on the fact that the code you have made is okay, you can make some a notes on what is good and not and then make adjustments.

Learn more about program drivers from

brainly.com/question/28027852

#SPJ1

4 0
2 years ago
How would a barcode reader be used in a healthcare industry?​
Leto [7]

Answer:

As you know the on going situation we are in, barcodes can be really useful for an example using them to check into a building that way when there is a infected person it is a really esay process to track down people that have been in that area.

5 0
3 years ago
Who is a u tuber that does fnaf stuff
Virty [35]

Answer:

i need points sry

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • A _______ is used to analyze and summarize your data without graphical support. A. PivotChart B. PivotTable C. chart D. table
    8·1 answer
  • Desirable workplace habits and skills include:
    6·2 answers
  • What are MS Word's default tabs?
    5·2 answers
  • Use induction on n to prove that fir all n&gt;=2, 2^n+3^n&lt;5^n
    11·1 answer
  • your computer running Windows 10 is doing some very strange things with operating system you are fairly certain it is not a hard
    13·2 answers
  • Which of the following illustrates an example of a string data type?
    15·2 answers
  • Match each law with the corresponding descriptions. Wassenaar Arrangement HIPIAA PCI DSS FERPA GLBA SOX A. controls the way fina
    13·1 answer
  • Pick a web browser (a leading one or perhaps a lesser-known one that you use) and examine the Privacy and Security features and
    10·1 answer
  • Technical safeguards involve the hardware and software components of an information system. group of answer choices true false
    9·1 answer
  • Why are salaried employees often excluded from overtime pay
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!