TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   yet another how do i ? (http://forums.techarena.in/software-development/1135748.htm)

Daren 06-03-2009 06:45 AM

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

Reegan 06-03-2009 08:22 AM

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);
}
}

Ackley 06-03-2009 08:32 AM

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

Daren 06-03-2009 05:06 PM

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


All times are GMT +5.5. The time now is 08:34 PM.