필터 지우기
필터 지우기

how can I write this simpler? (attachment)

조회 수: 1 (최근 30일)
Young Lee
Young Lee 2018년 10월 29일
댓글: madhan ravi 2018년 10월 30일
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,
  댓글 수: 2
madhan ravi
madhan ravi 2018년 10월 30일
Upload your code
madhan ravi
madhan ravi 2018년 10월 30일
We can’t debug a screenshot upload your code as text

댓글을 달려면 로그인하십시오.

채택된 답변

madhan ravi
madhan ravi 2018년 10월 30일
a = input('Please enter amount 1~100c')
x = a/25
y = floor((a)/25)
x1 = x/10
y1 = floor(x/10)
x2 = x1/5
y2 = floor(x1/5)
x3 = x2
y3 = 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)
  댓글 수: 2
Young Lee
Young Lee 2018년 10월 30일
thank you
madhan ravi
madhan ravi 2018년 10월 30일
Anytime :) did you solve your previous question?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by