Home arrow static arrow Java Programming [Archive] - Minimun of unknown number of values
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Minimun of unknown number of values
1 Duke Stars available
This topic has 5 replies on 1 page.

Posts:30
Registered: 7/1/04
Minimun of unknown number of values  
Jul 12, 2004 3:02 AM



 
Hi,
Anybody help me to write the java code to write a function to return the minimum of unknown number of values. Each time i will pass the values extracted from database to this function.First, the function will calculate total value. But it should always return the min. total value when all rows are finished. I tried somthing but did not work.
Thanks in advance,
Sai Ram
 

Posts:18,384
Registered: 21.03.00
Re: Minimun of unknown number of values  
Jul 12, 2004 3:33 AM (reply 1 of 5)



 
What?

/Kaj
 

Posts:30
Registered: 7/1/04
Re: Minimun of unknown number of values  
Jul 12, 2004 5:04 AM (reply 2 of 5)



 
Hi,
I think you have not undersood my problem. I want to write a function that should return a minimum value.It will get the values repetetively(so many) and calculate the total value and finally should return the min. otal value from all the total values calculated.
Help me please.
 

Posts:18,384
Registered: 21.03.00
Re: Minimun of unknown number of values  
Jul 12, 2004 5:20 AM (reply 3 of 5)



 
Hi,

In what kind of structure are you passing the values, and what type of values is it?

/Kaj
 

Posts:30
Registered: 7/1/04
Re: Minimun of unknown number of values  
Jul 12, 2004 5:28 AM (reply 4 of 5)



 
Hi,
The function I have defined is:
private double findMinimumTotalPrice(int month,double value,double bprice,double eprice)
{
double totalPrice=eprice + (bprice / (month*value));

}
 

Posts:55
Registered: 6/12/04
Re: Minimun of unknown number of values  
Jul 12, 2004 6:41 AM (reply 5 of 5)



 
try this out

public class min{            private double minimum = 9999999; //some big value             private double findMinimumTotalPrice(int month,double value,double bprice,double eprice)            {                        double totalPrice=eprice + (bprice / (month*value));                        if(totalPrice < minimum)                        {                                          minimum = totalPrice;                        }                        return totalPrice;            }             public double getMinimum()            {                           return minimum;            }             }  
 
This topic has 5 replies on 1 page.