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
Suppose your name was George Gershwin. Write a complete program that would print your last name, followed by a comma, followed b
NNADVOKAT [17]

Answer:

I will write the code in C++ and JAVA      

Explanation:

<h2>JAVA CODE</h2>

public class Main

{ public static void main(String[] args) {

       // displays Gershwin,George

     System.out.println("Gershwin,George"); }  }

<h2>C++ Code:</h2>

#include <iostream>

using namespace std;  

int main()

{  cout<<"Gershwin,George"; }    

// displays last name Gershwin followed by , followed by first name George

//displays Gershwin,George as output.

6 0
4 years ago
Read 2 more answers
Disadvantages of the divisional organization structure are _____. each division is able to operate independently from the parent
Fantom [35]

Answer:

Disadvantages:

1. A division may feel separated from the parent company because it has too much independence

2. This feeling of separation may lead to the division only worrying about meeting it's goals and objectives and not the companies as a whole

3. This system may be more expensive to operate and cannot share resources with other divisions

Explanation:

8 0
2 years ago
Sarah is having a hard time finding a template for her advertising buisness that she mah be able to use at a later date and also
irinina [24]

Answer: create a custom template

Explanation:

Since Sarah is having a hard time finding a template for her advertising business that she may be able to use at a later date and also make it available to her colleagues, her best option will be to create a custom template.

Creating a custom template will ensure that she makes the template based on her requirements and can tailor it specifically to her needs which then makes it unique.

6 0
3 years ago
Easy STEAM question :)
lorasvet [3.4K]

Answer:

Explanation:

A civil Engineer builds buildings, roads and bridges.

4 0
4 years ago
Read 2 more answers
Sound effects are located within the Microsoft® Office applications. In the Insert ribbon, what would you select to find pre-pro
babymother [125]
Sometimes clip art has sound files in them, it may have gotten updated though, that answer is the only one that could work.
7 0
3 years ago
Other questions:
  • Waterpower was first harvested by ancient societies using
    5·1 answer
  • What commands will reset a network interface in Linux?
    13·1 answer
  • The _________ contains approximately 200 million axons.
    13·2 answers
  • Draw the hierarchy chart and then plan the logic for a program that calculates a person’s body mass index (BMI).
    11·1 answer
  • You have been having issues with your printer, so you decide to learn more about how the printer works. You learn that if you re
    12·1 answer
  • You are an ISP. For the Address Block 195.200.0.0/16 a. If you have 320 Customers that need 128 addresses/customer - will there
    6·1 answer
  • Can someone please help me
    15·1 answer
  • Which statement assigns the value 140 to the variable streetNumber in Python?
    13·1 answer
  • When a number gets assigned to a variable that already has a value __________. the new number overwrites the previous value at t
    9·1 answer
  • Scott sends his backups to a company that keeps them in a secure vault. What type of backup solution has he implemented?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!