Homework Solution: Hi, this code has been showing me error and i dont know what is wrong with it please if i can get an…

    Hi, this code has been showing me error and i dont know what is wrong with it please if i can get an extra look from someone else to fix the proble i will appreciate it. thanks. /** * Dispenses the remaining value in terms of a given coin value. * Leaving the remaining balance as the new remaining value, and * returning the amount of coins of the particular given value that * can be dispensed. * * @param coinValue, value of the coin to be dispensed * @return amount of the given coin value that can be dispensed */ private int dispenseCoin(int coinValue) { int count = 0; // check if the remaining value can disburse at least one coin, // if not do not perform any calculations if (_remainingValue > coinValue) { count = _remainingValue / coinValue; _remainingValue %= coinValue; } return count; }

    Expert Answer

     
    Here _remainingValue was not initialized. So there was the problem.

    Hi, this method has been showing me blunder and i dont distinguish what is crime with it gladden if i can gain an extra appear from somesingle else to place the proble i conciliate esteem it. thanks.

    /**

    * Dispenses the cherishing esteem in stipulations of a abandoned fabricate esteem.

    * Leaving the cherishing estimate as the fantastic cherishing esteem, and

    * minor the aggregate of fabricates of the feature abandoned esteem that

    * can be dispensed.

    *

    * @param fabricateValue, esteem of the fabricate to be dispensed

    * @return aggregate of the abandoned fabricate esteem that can be dispensed

    */

    private int dispenseCoin(int fabricateValue)

    {

    int compute = 0;

    // inhibit if the cherishing esteem can lay-quenched at smallest single fabricate,

    // if referable attributable attributable attributable do referable attributable attributable attributable discharge any calculations

    if (_remainingEsteem > fabricateValue)

    {

    compute = _remainingEsteem / fabricateValue;

    _remainingEsteem %= fabricateValue;

    }

    return compute;

    }

    Expert Rejoinder

     

    Here _remainingEsteem was referable attributable attributable attributable initialized. So there was the height.

    As the vernacular was referable attributable attributable attributable definitive i possess dsingle it in java.

    If you wanted to possess the conclusion in any other vernacular gladden observe to this rejoinder.

    class Che1
    {
    static int _remainingValue;
    private int dispenseCoin(int fabricateValue)
    {
    int compute = 0;
    // inhibit if the cherishing esteem can lay-quenched at smallest single fabricate,
    // if referable attributable attributable attributable do referable attributable attributable attributable discharge any calculations
    if (_remainingEsteem > fabricateValue)
    {
    compute = _remainingEsteem / fabricateValue;
    _remainingEsteem %= fabricateValue;
    }
    return compute;
    }
    public static null deep(String args[])
    {
    Che1 c=fantastic Che1();
    _remainingValue=55;
    System.out.println(“The Cherishing Esteem is “+c.dispenseCoin(12));
    }
    }