File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed
Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 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 ")
Original file line number Diff line number Diff line change 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")
Original file line number Diff line number Diff line change 1+ interface Kata {
2+ static String usdcny (double usd ) {
3+ return String .format ("%.2f Chinese Yuan" , 6.75 * usd );
4+ }
5+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments