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
How many nibbles make one kilobyte​
Kazeer [188]
2000 nibbles I think correct me if I’m wrong
5 0
3 years ago
Read 2 more answers
The director of HR realizes that the KSAs currently used for hiring entry-level engineers are outdated. In order to establish wh
Vaselesa [24]

Answer:

Job analysis

Explanation:

The HR should preferably use job analysis.

6 0
3 years ago
What are the 2 levels of formatting in a word document
goldfiish [28.3K]

Answer:

Paragraph Styles and character formatting (font, color, etc.)

7 0
3 years ago
Which statement best describes network security
Andreyy89
<span>B.network security means all personal information is kept safe the network is not compromised and only authorized users had access 

Im pretty sure they ment has instead of had</span><span />
3 0
3 years ago
Read 2 more answers
Two different applications that make use of the barcode
jeyben [28]
Library books and items bought in stores are 2 different applications that make use of barcodes.
8 0
3 years ago
Other questions:
  • Hudson has to maintain confidential college data in a workbook. He needs two team members to help him update data in the specifi
    7·2 answers
  • Which of these is outside the scope of an art director's responsibility?
    12·2 answers
  • An engine you're servicing has electronically controlled cooling fans. Cooling fan 1 doesn't work but cooling fan 2 does. Which
    15·1 answer
  • _____ separation strategies (e.g., attacking and sabotaging others) are used by those for whom co-cultural segregation is an imp
    5·1 answer
  • What is the difference between a design pattern and a DLL?
    12·1 answer
  • How to solve a program that accepts a number as input and prints just the decimal portion
    15·2 answers
  • Complete the below method, isPalindrome(), that takes in a String and returns a boolean. The boolean should be true if the Strin
    7·1 answer
  • Which of the following are valid calls to Math.max? 1. Math.max(1,4) 2. Math.max(2.3, 5) 3. Math.max(1, 3, 5, 7) 4. Math.max(-1.
    9·1 answer
  • REPORT THIS USER. HE'S SHOWING HIS YK WHAT TO EVERYONE INCLUDING ME. HIS ACCOUNT PROFILE IS IN THE PICTURE BELOW
    14·1 answer
  • Basics of visual basic
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!