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
vesna_86 [32]
3 years ago
10

Write a program that reads a stream of integers from the console and stores them in an array. The array is then analyzed to comp

ute the average of all the values in the array and finally all of the values that are above the average should be printed out to the screen. Specifically, you must write three methods: main(), readIntoArray(), and printAboveAverage().
Computers and Technology
1 answer:
AVprozaik [17]3 years ago
4 0

Answer:

import java.util.Arrays;

import java.util.Scanner;

public class num4 {

   static int[] readInttoArray() {

       Scanner in = new Scanner(System.in);

       int [] intArray = new int [10];

       System.out.println("Enter Array values");

       intArray[0]= in.nextInt();

       for(int i = 1; i < intArray.length; i++){

           System.out.println("enter the next value ");

           intArray[i] = in.nextInt();

       }

       return intArray;

   }

   static void printAboveAverage(int [] intArray){

       System.out.println("The array entered is:"+ Arrays.toString(intArray));

       int sum =0;

       for(int i =0; i<intArray.length; i++){

           sum = sum +intArray[i];

       }

       double ave = sum/intArray.length;

       System.out.println("Average "+ave);

       for(int i = 0; i<intArray.length; i++){

           if(intArray[i]>ave){

               System.out.println(intArray[i]+" Is above average");

           }

       }

   }

   public static void main(String[] args) {

   readInttoArray();

   printAboveAverage(readInttoArray());

   }

}

Explanation:

  • Using Java Programming Language
  • The Three Methods are Created
  • readIntoArray() Uses Java's Scanner Class to prompt user to enter values to an array that is created with a for loop
  • The values entered are stored in the array array and returned whenever the method is called
  • printAboveAverage() Accepts an array as a parameter when called
  • Calculate the sum and average values in the array using a for loop
  • Uses an if statement to check for elements greater than the averaage and prints them out.
  • In the Main Method, Both methods readIntoArray() and  printAboveAverage() are called.

You might be interested in
Is a display, or monitor, considered a piece of computer hardware
9966 [12]
Yes. The monitor is considered as a piece of Computer Hardware. Computer hardware is what you can physically touch, like the keyboard, mouse, monitor, disk drive, and so on.

I hope this answers your question.

Thank you,
Otaku
3 0
3 years ago
1. Describe the sequencing of factors influencing health status codes for patients that also have chronic conditions being manag
Vesnalui [34]
Bubyggyy tvtvtvttfrcrt
4 0
3 years ago
Why will it take so long to complete the high-speed rail route?
koban [17]
It will take a while for all of the necessary safety inspections. 
3 0
3 years ago
Read 2 more answers
BUURTAIS
Alisiya [41]

Answer:

what I'm confused ???????

Explanation:

?

4 0
3 years ago
Marly is using her smartphone to review a webpage that she created. The formatting and alignment of webpage elements is incorrec
Margaret [11]

Answer:

She needs a responsive design

Explanation:

The website needs to detect what kind of device the user is using. It could be by the window size (not very accurate), or a piece of code to figure out the device being used. Once it knows what device is being used, and the size of the page, it should change its layout to fit the design.

3 0
3 years ago
Other questions:
  • Describe a situation where it would be advantageous to use the copper tape or aluminum foil instead of the A and B push buttons
    7·2 answers
  • Your corporation hosts a Web site at the static public IP address 92.110.30.123.
    13·1 answer
  • Whoever answers int the next 15 minutes will get brainliest. To get brainliest, it also has to be the correct answer. 8 points r
    11·2 answers
  • is there anybody out there who is a social butterfly like me? If so then you can tlk to me on this. and to anybody out there tha
    12·1 answer
  • Which sentence(s) below are true?a. IP stands for Internet Protocol.b. In most home networks IP addresses are assigned by the In
    6·1 answer
  • Jane is creating a slide that will have a large heading and number of bullet points below it. What slide format should she use?
    12·1 answer
  • Why stress testing is needed?​
    14·2 answers
  • Question 1 (1 point)
    9·2 answers
  • You’ve been tossed into an insane asylum. What do you tell the people there to prove to them that you don’t belong inside?
    7·2 answers
  • NO LINKS Please
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!