Ad
  • Custom User Avatar

    Good to know! Super useful for very small values of p0 and or very large values of p. It really helps to be familiar with compound interest/annuities, otherwise it's really easy to get lost working out the logic.

  • Custom User Avatar

    The percent inputs are not in decimal form. Dividing percent by 100 gives you the correct number to work with.

    As for why it's 1+percent, it may help to think in terms of money.

    • An apple costs $5.00. Tax is 20%. What is the total cost?
    • Total Cost = Cost + Tax
    • Total Cost = 5 + 5*0.2 --- "Five dollars plus twenty percent of five dollars."
    • Total Cost = 5(1 + 0.2) --- Distributive property. Ax + Bx = x(A + B).
    • Total Cost = 5.10

    The "2 percent" you are referring to was just an example. In the actual exercise, the percent value is variable.

  • Custom User Avatar

    Not sure if something updated but it appears System.out.print now works to some extent. The only condition is that your code compiles perfectly. Once that's satisfied, you should be able to print to console messages in your solution. You can also modify the example test cases to print out each case.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    In your code, you are always returning the same answer no matter what n is. The design here is to allow any number, n, to be used and spit out in reverse.