I have wrote the following code. just wondering if there is a much simpler way to write the same code…. I feel like Im going around long way for this.
a = input('Please enter amount 1~100c','s')
x = rem(str2num(a),25); y = floor(str2num(a)./25);
x1 = rem(x,10); y1 = floor(x./10);
x2 = rem(x1,5); y2 = floor(x1./5);
x3 = rem(x2,1); y3 = floor(x2./1);
fprintf('Quaters (25c) X %d\n',y) fprintf('Dimes (10c) X %d\n',y1)fprintf('Nickels (5c) X %d\n',y2)fprintf('Pennies (1c) X %d\n',y3)
sorry for inconvenience,
Best Answer