Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 06-03-2009
Member
 
Join Date: Feb 2009
Posts: 96
yet another how do i ?

i need to make a method that receives an array and an average
i need to get the elements in the array that are higher then the average.

now i have a method called aveArray which gives me an average that is called by my main.

my question is how do i make the method called highPrices call on the aveArray method and how do i set it up so that all the higher then average prices display in a dialog box?

sorry about these questions my book really sucks
Reply With Quote
  #2  
Old 06-03-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: yet another how do i ?

public class ArrayAverage{
public static void main(String[] args) {
double nums[]={1.0,2.3,3.4,4.5,40.5};
double result=0.0;
int i=0;
for(i=0; i < nums.length; i++){
result=result + nums[i];
}
System.out.println("Average is =" + result/nums.length);
}
}
Reply With Quote
  #3  
Old 06-03-2009
Member
 
Join Date: Dec 2008
Posts: 183
Re: yet another how do i ?

Hello Daren,

Though you have mentioned your requirements but you have forget to mentioned in which Programming language you need your Output, because we could expect average with array using JAVA, C# and also with the Excel, so please mention the programming language.

Regards
Reply With Quote
  #4  
Old 06-03-2009
Member
 
Join Date: Feb 2009
Posts: 96
Re: yet another how do i ?

needs to be in JAVA

the array is populated by input boxes and is in another method
i have 4 methods all together

input for the array
sumArray()
avgArray()
highPrices() <---- i need this one
everytime i do it it says it cant accept more then one type or something like that
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search



All times are GMT +5.5. The time now is 04:35 AM.