sum = 0.
for (all numbers to sum) {
obtain "next".
sum += next.
}
product = 1.
for (all numbers to multiply) {
obtain "next".
product = product * next.
}
initialize max.
for (all numbers to examine) {
obtain "next".
if (next > max) {
max = next.
}
}
double dollars1 = 0.01 + 0.05 + 0.10 + 0.25;
double dollars2 = 0.25 + 0.10 + 0.05 + 0.01;
System.out.println("Output is:\n");
System.out.println(dollars1);
System.out.println(dollars2);
Output is:
0.41000000000000003
0.41