瀏覽單個文章
dwight1116
Registered User
 
dwight1116的大頭照
 

加入日期: Jul 2003
文章: 343
經過了幾天的思考
同學間也是霧煞煞
弟還是沒有頭緒,只會這種簡單的:

在M file中指定function
function [value, radius] = sun(angle)
radius=angle*pi/180
value=sin(radius)
在工作視窗中輸入sun
>> sun(30)
radius = 0.5236
value = 0.5
ans = 0.5

這種題目我實在是想不透
↓題目↓
You are working for a local grocery store, and your job is to determine how to break down customers’ change. That is, if a customer’s total charge came to $221, and they handed you a $1000 bill, the cash register will tell you that you owed them $779 change;
the best way to breakdown $779 would be one $500 bill, one $200 bill, one $50 coin, two $10 coins, one $5 coin, and four $1 coins.

Please write a m-file (the filename should be SID_hw5.m), which prompt the user for a customer’s total charge and total payment; then your program should compute how much charge the customer is due and how this change should be broken down so that the customer receives the minimum number of bills and coins. You will have bills such as $2000, $1000, $500, $200, $100, and coins of $50, $10, $5,
$1, $0.25,$0.1,$0.05 and $0.01 in the cash register.and in the cash register.

加入美式的幣制,0.25是 quarter,0.1是 dime,0.05是 nickel,0.01是 penny。
有兩個input,一個是顧客給的錢,一個是顧客的消費金額。再加上條件判斷,若給的錢少於消費金額時,應該顯示「錢不夠」之類的。如果是正常情況的話,ouput 應該是每種紙鈔與硬幣的數量。

即將是dead line了
請問剎那還有各位大大該怎麼寫呢
非常感謝Cudacke大大的解答,但是您的寫法對弟來說太深奧了
弟是個初學者,希望能用最簡單的方法寫出。
舊 2003-12-22, 09:11 PM #10
回應時引用此文章
dwight1116離線中