In order to accomplish this work as quickly as possible, we will not use keyboar
ID: 3527380 • Letter: I
Question
In order to accomplish this work as quickly as possible, we will not use keyboard or file input. Instead, you may assign the 10 values to your initial arrays in the programs. Using initializer lists to load them with the data types expected for each exercise. Please use methods to do each task .Pass your arrays to the method to complete each task. Write a program that takes 10 floating-point numbers as inputs. The program displays the average of the numbers followed by all the numbers that are greater that the average. As part of your design, write a method that takes an array of doubles as a parameter and returns the average of the data in the array.Explanation / Answer
import TerminalIO.*;
class array3
{
public static void main(String[]args)
{
for (int y=0;y<9;y++)
{
KeyboardReader reader=new KeyboardReader();
double[] array=new double[];
System.out.println("Please enter the numbers");
array[y]=reader.readFloat();
double finalAverage;
finalAverage=array.getAverage(array[y]);
for (int j=0;j>=9;j++)
{
if (array[y]>finalAverage)
{
System.out.println("The numbers higher than final average are"+array[y]);
}
System.out.println("Hence, the final average is"+finalAverage);
}
}
public static double getAverage(double array[y])
{
int i=0;
array[i]=array[y];
double sum;
for (i=0;i<=9;i++)
{
sum=sum+array[i];
}
double average=(sum)/(10);
return average;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.