Skip to content

Commit 76ea22a

Browse files
authored
interest-is-interesting: remove negative balance (#1695)
1 parent fff4587 commit 76ea22a

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

exercises/concept/interest-is-interesting/.docs/hints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## 2. Calculate the interest
1212

13-
- When calculating interest, it might be helpful to convert a negative balance to a positive one. One could use arithmetic here, or one of the methods in the [`Math` class][docs-microsoft.com-system.math].
13+
- When calculating interest, it might be helpful to notice that `InterestRate` returns a percentage.
1414

1515
## 3. Calculate the annual balance update
1616

exercises/concept/interest-is-interesting/.docs/instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
In this exercise you'll be working with savings accounts. Each year, the balance of your savings account is updated based on its interest rate. The interest rate your bank gives you depends on the amount of money in your account (its balance):
44

5-
- -3.213% for a negative balance.
5+
- 3.213% for a negative balance (balance gets more negative).
66
- 0.5% for a positive balance less than `1000` dollars.
77
- 1.621% for a positive balance greater or equal than `1000` dollars and less than `5000` dollars.
88
- 2.475% for a positive balance greater or equal than `5000` dollars.

exercises/concept/interest-is-interesting/.meta/Exemplar.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public static float InterestRate(decimal balance)
66
{
77
if (balance < 0.0m)
88
{
9-
return -3.213f;
9+
return 3.213f;
1010
}
1111

1212
if (balance < 1000.0m)
@@ -24,7 +24,7 @@ public static float InterestRate(decimal balance)
2424

2525
public static decimal Interest(decimal balance)
2626
{
27-
return Math.Abs(balance) * ((decimal)InterestRate(balance) / 100);
27+
return balance * ((decimal)InterestRate(balance) / 100);
2828
}
2929

3030
public static decimal AnnualBalanceUpdate(decimal balance)

exercises/concept/interest-is-interesting/InterestIsInterestingTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,30 @@ public void Large_third_interest_rate()
6868

6969
[Fact]
7070
[Task(1)]
71-
public void Minimal_negative_interest_rate()
71+
public void Rate_on_minimal_negative_balance()
7272
{
73-
Assert.Equal(-3.213f, SavingsAccount.InterestRate(-0.000001m));
73+
Assert.Equal(3.213f, SavingsAccount.InterestRate(-0.000001m));
7474
}
7575

7676
[Fact]
7777
[Task(1)]
78-
public void Small_negative_interest_rate()
78+
public void Rate_on_small_negative_balance()
7979
{
80-
Assert.Equal(-3.213f, SavingsAccount.InterestRate(-0.123m));
80+
Assert.Equal(3.213f, SavingsAccount.InterestRate(-0.123m));
8181
}
8282

8383
[Fact]
8484
[Task(1)]
85-
public void Regular_negative_interest_rate()
85+
public void Rate_on_regular_negative_balance()
8686
{
87-
Assert.Equal(-3.213f, SavingsAccount.InterestRate(-300.0m));
87+
Assert.Equal(3.213f, SavingsAccount.InterestRate(-300.0m));
8888
}
8989

9090
[Fact]
9191
[Task(1)]
92-
public void Large_negative_interest_rate()
92+
public void Rate_on_large_negative_balance()
9393
{
94-
Assert.Equal(-3.213f, SavingsAccount.InterestRate(-152964.231m));
94+
Assert.Equal(3.213f, SavingsAccount.InterestRate(-152964.231m));
9595
}
9696

9797
[Fact]

0 commit comments

Comments
 (0)