function str=charge()
coins={' quaters' ' dimes' ' nickels' ' pennies'};
coin={' quater' ' dime' ' nickle' ' penny'};
quantity={'zero' 'one' 'two' 'three' 'four'};
x=input('enter the amount for charge [0.01-0.99] ->');
while (x<=0 | x>=1)
    disp('input change between 0.00 and 0.99 only');
    x=input('enter the amount for charge [0.01-0.99] ->');
end
fprintf('\nChange of $%g is best given as:\n\n',x);
k=[.25 .10 .05 .01];
for n=1:4
    num=fix(x/k(n));
    x=x-num*k(n);
    if num==1
        disp(strcat(quantity(num+1) , coin(n)));
    elseif num>1
        disp(strcat(quantity(num+1) , coins(n)));
    end
end

为什么以上代码运行时会有几个数字不对呢?
比如说input0.47,最后会少一位,这是为什么呢?

为什么以上代码运行时会有几个数字不对呢?
比如说input0.47,最后会少一位,这是为什么呢?