Skip to content

Commit 3dc11ae

Browse files
feat: kata/usd-equals->-cny (#804)
* docs: kata description * chore: invalid directory character * feat: kata/usd-equals->-cny Signed-off-by: Capt. Cutlass <5120290+ParanoidUser@users.noreply.github.com>
1 parent 563d35f commit 3dc11ae

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

kata/8-kyu/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
- [Unexpected parsing](unexpected-parsing "54fdaa4a50f167b5c000005f")
220220
- [Unfinished Loop - Bug Fixing #1](unfinished-loop-bug-fixing-number-1 "55c28f7304e3eaebef0000da")
221221
- [Up and down, the string grows](up-and-down-the-string-grows "644b17b56ed5527b09057987")
222+
- [USD => CNY](usd-equals-cny "5977618080ef220766000022")
222223
- [Volume of a Cuboid](volume-of-a-cuboid "58261acb22be6e2ed800003a")
223224
- [Weird Java Array](weird-java-array "6607fc50c6494c000f1a08fc")
224225
- [Welcome to the City](welcome-to-the-city "5302d846be2a9189af0001e4")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# [USD => CNY](https://www.codewars.com/kata/usd-equals->-cny "https://www.codewars.com/kata/5977618080ef220766000022")
2+
3+
Create a function that converts US dollars (USD) to Chinese Yuan (CNY) . The input is the amount of USD as an integer, and the output should
4+
be a string that states the amount of Yuan followed by 'Chinese Yuan'
5+
6+
### Examples (Input -> Output)
7+
8+
```
9+
15 -> '101.25 Chinese Yuan'
10+
465 -> '3138.75 Chinese Yuan'
11+
```
12+
13+
The conversion rate you should use is 6.75 CNY for every 1 USD. All numbers should be represented as a string with 2 decimal places. (e.g. "
14+
21.00" NOT "21.0" or "21")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Kata {
2+
static String usdcny(double usd) {
3+
return String.format("%.2f Chinese Yuan", 6.75 * usd);
4+
}
5+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import org.junit.jupiter.params.ParameterizedTest;
4+
import org.junit.jupiter.params.provider.CsvSource;
5+
6+
class USDtoCNYTest {
7+
@ParameterizedTest
8+
@CsvSource(textBlock = """
9+
15, 101.25 Chinese Yuan
10+
465, 3138.75 Chinese Yuan
11+
""")
12+
void sample(int usd, String expected) {
13+
assertEquals(expected, Kata.usdcny(usd));
14+
}
15+
}

0 commit comments

Comments
 (0)