|
-
Help with an arrays assignment
The assignment is basically having to take 10 floating point numbers as inputs in an array and then finding the average. The program should then return the average followed by all of the numbers greater than the average.
I already figured out how to find the average and displaying it but i cant figure out how to display the numbers greater than the average.
This is what i have so far if it helps any
import java.util.Scanner;
public class ArraysAverage
{
public static void main(String[] args)
{
int[] list=new int[10];
int num = 0, bignum=0;
float sum = 0;
Scanner reader = new Scanner(System.in);
for(int i=0; i<list.length; i++)
{
System.out.print("Enter a number: ");
list[i] = reader.nextInt();
sum += list[i];
}
float avg = sum/list.length;
System.out.println("The average is: " + avg );
}
public static double Total(int[] list){
double Total = 0;
for(int i=0; i<list.length; i++)
{
Total += list[i];
}
return Total;
}
public static double average(int[] list, double Total){
double average = (Total/(list.length));
return average;
}
}
Similar Threads
-
By aesoprock00 in forum Java
Replies: 2
Last Post: 02-11-2006, 11:17 PM
-
By premartha in forum C++
Replies: 3
Last Post: 10-21-2005, 10:06 AM
-
Replies: 15
Last Post: 05-09-2001, 04:40 AM
-
By Brian Leung in forum VB Classic
Replies: 12
Last Post: 06-20-2000, 03:06 PM
-
By Brian Leung in forum VB Classic
Replies: 0
Last Post: 06-20-2000, 09:47 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks