id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > test2024_02_08_P1SLHL_comboNum
prev  |  next  |  chance

Write a method that accepts two positive numbers with the same number of digits, 'num1' and 'num2'. Return a new number that combines the digits of 'num1' and 'num2' by alternately taking digits from each number. For example, if 'num1' is 753 and 'num2' is 246, you would return 725436. If you look carefully at the result you will notice that the 7, 5, and 3 came from 753, which was 'num1', while the 2, 4, and 6 came from 246, which was 'num2'. In solving this problem you are NOT allowed to use strings, arrays, or ArrayList. Preconditions: 'num1' and 'num2' will both be positive and will have the same number of digits. Look at the test data for more examples.


test2024_02_08_P1SLHL_comboNum(45, 18) → 4158
test2024_02_08_P1SLHL_comboNum(123, 456) → 142536
test2024_02_08_P1SLHL_comboNum(8913, 4571) → 84951731

...Save, Compile, Run (ctrl-enter)

public int test2024_02_08_P1SLHL_comboNum(int num1, int num2) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 260

Copyright Nick Parlante 2017 - privacy