Answer to Question #289770 in Java | JSP | JSF for Vij

Question #289770

In a science research lab, the combination of two nuclear chemicals produces initial energy as X. This energy X changes at a consistent rate R every second. The scientist wishes to calculate the total energy produced if the reaction is allowed to occur for N seconds.



Write an algorithm to find the total



energy produced.

1
Expert's answer
2022-01-22T16:34:45-0500
public class Main {
    public static void main(String[] args) {
        int x = 10;
        int r = 2;
        int n = 5;
        int total = x;
        for (int i = 0; i < n; i++) {
            total += (x + r);
            x += r;
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog