If statement problem (tip calculator)
이전 댓글 표시
Im having trouble with this problem. I basically have to create a script that will receive an input as a billing amount and party size with an output calculation of a tip based on two conditions. The billing amount and party size should be considered during the calculations; if the bill is less than $10.00 the tip will be $1.80 and if the party size if greater than 2 persons an additional %32 will be included, if the bill is between $10.00 and $60.00 the tip is %18 and if the party size if greater than 4 persons an additional $4.20 will be included, if the bill is above $60.00 the tip is %20 and if the party size if greater than 6 persons an additional %13.33 will be included
댓글 수: 1
@Erasmo Hinojosa: what is your question?
Note that your code concept will not work: you either need to use a loop with indexing, or get rid of the if's altogether and use logical indexing (better). if statements do not operate on different parts of vectors in the way that you are trying to use them.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Functional Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!