How do I get my while loop to execute?
This is a program for computing a close enough value for the half-life of radioactive carbon-14.
The loop should terminate if the absolute value of the differences is within an epsilon of 1.0E-7.
When I run the program nothing happens. What's wrong with my while loop?
The instructions says that the while loop should be controlled by a comparison of half of the initial amount and the computed amount remaining.
public class Lab4Part2
public static void main(String args)
final double EPSILON = 1.0E-7;
final double INITIAL_AMOUNT = 2.0E-5;
final double DECAY = 1.14E-4;
double amount = INITIAL_AMOUNT;
int year = 0;
while (EPSILON < Math.abs(2.0E-5 / 2) - amountRemaining))
amountRemaining = amount - (DECAY / 100) * amount;
System.out.println("The approximate value for the half-life of carbon-14 is " + year + " years.");