What is "annual balance update" in "Interest is Interesting" task?

Hello.
I’m stuck with the task “Interest is Interesting”. One of functions to implement is “calculate the annual balance update”. What is this “annual balance update”? Is it some common financial term? What is the formula?
The description of the task is unclear.

1 Like

What language/track is this for?

Presumably one of C#, Clojure, F#, Go. The instructions on all of these tracks are essentially the same.

The second sentence in the instructions explains what an annual balance update is:

“Each year, the balance of your savings account is updated based on its interest rate”

So the only financial term you should know is the “interest rate”.

1 Like

Each year, the balance of your savings account is updated based on its interest rate.

Given a specific balance (function input) and interest rate (based on step one), compute the new balance after you’ve added the interest earned.

1 Like

The wording needs to change on that exercise because many people will not know what an “annual balance update” is and will not be able to calculate it. Therefore they will get stuck and not be able to complete the exercise.

  1. That exercise has a pretty high competition rate on the C# track at 89% with over 6,000 students completing, which suggests most people figure it out.
  2. If someone does get stuck, they can get her from multiple places.

That said, you can propose (on the forum) different wording and see if you can convince the track maintainers that a change is warranted!

1 Like

If you do a search on the internet for “annual balance update” you should find something explaining what that is. I found nothing.

It’s not a special term. Annual means once a year. Update means to change the value. Balance is the thing you are changing. “For every year (annual) change (update) the balance.”

Are you unfamiliar with any of those words?

1 Like

It is a simple calculation. I think something is off with the test because mine fails every time. Here is an example error (C++):

FAILED:
  REQUIRE_THAT( annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001) )
with expansion:
  0.5 and 0 are within 0.0001% of each other
at /tmp/interest-is-interesting/interest_is_interesting_test.cpp:112

If you show your code, perhaps the problem is with the code rather than the tests. We can not know, though, unless we can see what is causing that response in the tests.

1 Like

There are over 1,000 solutions in C++ which pass the tests. Either all of those are wrong, or your code has a bug :smile:

What is the test calling and expecting? Do you understand why? What does your code return?

1 Like

@kotp @IsaacG I figured it out. It was so easy. I must have had a typo and did not look at the error close enough! Thanks for your help. Maybe the word “update” threw us off.

I would have written the instructions for task 3 like this:

Implement the annual_balance function by calculating the balance with the interest rate for the year.

It probably would have been easier for us to help you see that if you had shown your code. Sorry for any frustration from not being able to spot it, but I think it is something that we all go through. Sometimes we are too close to the code to see what may be obvious to others, even our “other selves” once we step away from the code for a bit.

I will often avoid the use of “implement” since it is often used incorrectly, (It is not the easiest of English words), even though here it is precisely accurate, and can not be misinterpreted from its other meaning of “tool” or “use”.

But if this description is coming from Problem Specifications, not all languages have functions, and beyond that, not all solutions need to calculate, or rather, have this specific function calculate, but it could use a lookup, or some other mechanism. It is often better to consider instruction that describes the result, rather than the solution of how to get to that result.

But it is good to see how others would write the instructions, it gives a bit of insight as to how one thinks about the problem, especially once one solves the problem. For you, your solution likely calculates the balance using a function of that name. Even though I have not seen the code, I can tell that from the way you describe the desired solution.

2 Likes

It is from a concept exercise and thus implemented individually.

If this is specifically about the wording in the C++ track, I am always open to suggestions, as I wrote the exercise. I am always happy to improve the track.

1 Like

@vaeng I did the exercise already. It is just that some people may have an easier time if it was reworded differently.

@kotp I did not show my code because I had changed it a few times. I must have had a typo the first time I attempted the exercise. I ended up completing the exercise. vaeng’s solution is the same as mine for annual_balance_update().