Interest is Interesting: Test violates problem description

0.5% for a positive balance less than 1000 dollars.

public void Minimal_first_interest_rate()
{
    Assert.Equal(0.5f, SavingsAccount.InterestRate(0m));
}

0 is not a positive number. Interest rate for zero balance has not been defined.

What would you like to see as a potential fix in the documentation? For context, this is the surrounding text.

3.213% for a negative balance (balance gets more negative).
0.5% for a positive balance less than 1000 dollars.
1.621% for a positive balance greater than or equal to 1000 dollars and less than 5000 dollars.
2.475% for a positive balance greater than or equal to 5000 dollars.

Simply removing the word “positive” from the following line will make the problem description consistent with the test.

0.5% for a positive balance less than 1000 dollars.

Balances less than 1000 includes negative balances, which has a different rate.

Instead of “positive”, “non-negative” can be used. Alternatively, the zero condition can be added explicitly:

0.5% for a non-negative balance less than 1000 dollars.

0.5% for a 0 balance or a positive balance less than 1000 dollars.

The whole section probably needs to be changed consistently.

3.213% for a balance less than 0 dollars (balance gets more negative).
0.5% for a balance greater than or equal to 0 dollars and less than 1000 dollars.
1.621% for a balance greater than or equal to 1000 dollars and less than 5000 dollars.
2.475% for a balance greater than or equal to 5000 dollars.

2 Likes

Even though this is wordy, I do think it’s clear

Balance Range Interest Rate
balance < 0 3.213% (see note)
0 ≤ balance < 1000 0.5%
1000 ≤ balance < 5000 1.621%
balance ≥ 5000 2.475%

Edit - We’d add this note to the end.

~~~~exercism/note~~~~
A negative balance with a positive interest rate results in a smaller balance.
~~~~
1 Like

Loved the table. The note about the negative balance getting more negative is lost here, so maybe it’d be clearer to put “-3.213%” as interest rate.

EDIT: Although that may be misinterpreted as making the negative less negative. So maybe keeping the note in the table?

1 Like

Yeah, putting down -3.213% would create problems I think for folks copying and pasting the numbers into their code. The tests for negative numbers would likely fail unless they handle flipping the rate to be positive so the balance goes down. I updated the table to include a note at the bottom for negative balances.

1 Like

Shouldn’t this be 0 ≥ balance < 1000?

Since the balance less than zero is handled in the line above.

For testing purpose, the rate for 0 matters, in order to report the rate that is wanted, but the result of a balance of 0 being applied to any percentage will result in 0, from multiplication rules, regardless of the rate.

In my opinion, the table gives too much away. The student is supposed to translate the problem description into a tabular format in code (perhaps switch), but the table almost makes it possible to copy-paste with trivial changes.

One of the comments suggested using “non-negative” instead of “positive”. Why was that not acceptable?

2 Likes

No? That means 0 is greater than or equal to balance so the balance would be zero or less than zero. We want balances of zero or higher up to 1000.

1 Like

I didn’t say whether it was acceptable or not. However, I’m not sure adding a third term here adds clarity. Students may get stuck on the difference between positive and non-negative, which would be a distraction from the exercise.

This is a concept exercise, it is meant to be simple. The design.md for the exercise states that the objective is to learn about floating-point numbers.

In fact, switch statements come later in the syllabus tree, so they are not expected to be used at all.

If-statements is a prerequisite, so the idea here is to use them to branch. As they are not the focus, there is no problem to be obvious about it.

1 Like

Given that this is a track concept and not a problem spec exercise, this is purely for the track maintainer(s) to decide on.

Personally, I’m not convinced the prose necessarily needs to be more exact … but the track maintainer(s) will make that call.

3 Likes

Another option for the track maintainer is to leave the instructions as they are, and change the test case to check the interest rate at $1 (or 1 cent) instead of 0.

If the interest rate is Interest / Principal then it is reasonable for the instructions to leave the interest rate at 0 undefined.

@IsaacG Maybe move this thread to Programming C#? cc @ErikSchierboom

Moved to the appropriate category