Skip to content

Commit 63e7e57

Browse files
committed
feat: kata/usd-equals->-cny
1 parent 0e22e66 commit 63e7e57

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

kata/8-kyu/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +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")
222+
- [USD => CNY](usd-equals-cny "5977618080ef220766000022")
223223
- [Volume of a Cuboid](volume-of-a-cuboid "58261acb22be6e2ed800003a")
224224
- [Weird Java Array](weird-java-array "6607fc50c6494c000f1a08fc")
225225
- [Welcome to the City](welcome-to-the-city "5302d846be2a9189af0001e4")

kata/8-kyu/usd-equals-cny/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# [USD => CNY](https://www.codewars.com/kata/usd-equals->-cny "https://www.codewars.com/kata/5977618080ef220766000022")
22

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 be a string that states the amount of Yuan followed by 'Chinese Yuan'
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'
45

56
### Examples (Input -> Output)
7+
68
```
79
15 -> '101.25 Chinese Yuan'
810
465 -> '3138.75 Chinese Yuan'
911
```
1012

11-
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. "21.00" NOT "21.0" or "21")
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")
+5
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+
}
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)