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

 

makeChange


We want try and make exact change with the coins we have. We have only pennies and nickels. Return the number of pennies to use, assuming we always use as many nickels as we can. Return -1 if it can't be done.


makeChange(4, 1, 9) → 4
makeChange(4, 1, 10) → -1
makeChange(4, 1, 7) → 2

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

public int makeChange(int pennies, int nickels, int cost) { }

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: 14

Copyright Nick Parlante 2017 - privacy