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
Francisco is becoming a dad for the first time. He feels relatively clueless about all things involving parenting and is looking
sergij07 [2.7K]

The source which would most likely fit Francisco's needs is: B. The US Children’s Bureau.

<h3>What is the US Children’s Bureau?</h3>

The US Children’s Bureau can be defined as a federal agency of the United States of America which was founded under the United States Department of Health and Human Services by William Howard Taft in 1912.

The main purpose of the US Children’s Bureau is to improve the lives of children and families through special programs that are designed and developed to:

  • Prevent or reduce child abuse.
  • Foster child care.
  • Enhance child adoption.

In conclusion, the US Children’s Bureau would help Francisco learn about the basics such as installing a car seat and childproofing his home.

Read more on US Children’s Bureau here: brainly.com/question/6043069

5 0
3 years ago
What kind of voltage do solar cells generate? Solar cells produce ______ voltage which is not usable by most household appliance
beks73 [17]

Answer:

open circuit voltage

Explanation:

7 0
3 years ago
_____ is the practice of using the internet to provide healthcare without going to a doctor’s office or hospital.
Molodets [167]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The correct answer to this question is Telehospital.

Because Telehospital provides services where patients treated online by a physician. It is like providing medicine services remotely to patients.  

A live secure connection is established between patient and physician where physicians diagnose patient disease and recommend transcription.

It is the same as a typical visit to the hospital, except the doctor and patient are not on the same physical location. They are connected with each other remotely.

While other options are not correct because: telenursing is related to providing nursing services online, where telehealth is providing all health care services, it also includes education, training, and administrative services also. While teledoctor and telehospital used interchangeably.

But telehospital is the most and widely used term to diagnose patients remotely by physicians.

7 0
3 years ago
Read 2 more answers
Search the web to discover the 10 most common user-selected passwords, and store them in an array. Design a program that prompts
Airida [17]

Answer:

userpassword = {"123456",

"password",

"123456789",

"12345678",

"12345",

"111111",

"1234567",

"sunshine",

"qwerty",

"abc123"}

#We define the function that prompts the user for a password

def user_passinput():

   password = input("Choose enter a password: ")

   return password

#Function that checks the password

def check_password():

   count = 0

   check_pass = user_passinput()

   if check_pass in userpassword:

       print("Yay!! you entered the correct password")

   elif count <10:

           count = count+1

           print("Please try again")

          user_passinput()

   else:

       print ("Maximum tries exceeded")

check_password()

Explanation:

Using Python for this code, in the first line of the code, we list the dictionary of 10 most common passwords searched on the web. In line 12, we define the function that will demand the user to enter a password and return the value the user entered. Line 16 defines the function that checks if the password is common and prints to the screen either "Yay!! you entered the correct password", "Please try again" or "Maximum tries exceeded" depending on the condition that is satisfied. The last line of the code calls the check_password() function, which actually initiates the designed program.

7 0
4 years ago
A special symbol that is used as an underlining structure to an agenda
Gnesinka [82]
What? what are you asking
6 0
3 years ago
Other questions:
  • Write the following method to display three numbers in increaseing order:
    5·1 answer
  • At what two layers of the osi model are lan and wan protocols likely to differ??
    7·1 answer
  • A senior center would like to add a new computer to their library so that members can check their email and read book reviews
    11·2 answers
  • Why can black holes not be seen?
    5·1 answer
  • A device in electricity that is analogous to a restriction in a water pipe is:
    11·1 answer
  • Jamie is preparing a presentation on his laptop for his college annual event. He inserts audio and video files into the presenta
    11·2 answers
  • We need ____ pointers to build a linked list.
    6·1 answer
  • The programming interface for a legacy motor controller accepts commands as binary strings of variable lengths.
    15·1 answer
  • PLZ PLZ PLZ PLZ HELP I ONLY HAVE 5 MINUTES IT SAYS THE SUBJECT IS COMPUTERS AND TECHNOLOGY BUT ITS ACTUALLY MEDIA LIT
    5·1 answer
  • Elena wrote the following code in Scratch to have the sprite move and then turn around. However, the code does not work as expec
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!