What I’m trying to do is run 60 trials of this program. Each time I want the value of K to go down 1, until K=0. Currently i have only been able to get the program to repeat the same answer 60 time.
package heatloss;
/**
*
* @author eric
*/
public class HeatLoss {
public static void heatloss(double x, double m, double a, double k) {
double heatloss = x - m * (x - a);
if (k == 0) {
System.out.println("Done With Trials");
}
else {
System.out.println(heatloss);
heatloss(x,m,a,k-1);
}
}
public static void main(String[] args) {
double k = 60;
double old = 60+k;
double m = 0.10;
double air = 40;
heatloss(old, m ,air, k-1 );
}
}
The value of
kis decreasing, because your function runs 60 times, as you said. However:is a constant value, because it does not relate to
kin any way, and thusprints the same value every time.