pascal問題

2008-10-18 2:18 am
By using CASE .. OF ONLY , write a money conversion program to get inputs of the following format:
U 1000 A
to convert 1000 US dollars into Australian. Use the following table for conversion.

Australian=5.94hkd
Britain=12.04hkd
Canada=5.55hkd
German=4.97hkd
Japan (100$)=7.68hkd
USA=7.76hkd

希望有人可以幫幫我..我岩岩學
更新1:

小Dave 你可唔可以用CASE...OF去做..因為我係要用CASE...OF先可以

回答 (1)

2008-10-18 6:21 am
✔ 最佳答案
Part1:
program money ;
var money1,money2 : real;
var input,output : real;
var country:integer;
var inputk,outputk : string;
var error:boolean;
begin
writeln('Please choose the kind of the input money');
writeln('1: Hong Kong dollar 2: Australian dollar 3: British pound');
writeln('4: Canadian dollar 5: Deutsche Mark 6: Japanese yen 7: US dollar');
write('Type the kind of money here:');readln(country);
If (country = 1) then begin input:=1; inputk := ' Hong Kong dollar(s)' end
else if (country = 2) then begin input:=5.94; inputk :=' Australian dollar(s)' end
else if (country = 3) then begin input:=12.04; inputk :=' British pound(s)' end
else if (country = 4) then begin input:=5.55; inputk :=' Canadian dollar(s)' end
else if (country = 5) then begin input:=4.974; inputk :=' Deusche Mark(s)' end
else if (country = 6) then begin input:=0.0768; inputk :=' Japanese yen(s)' end
else if (country = 7) then begin input:=7.76; inputk :=' US dollar(s)' end
else error:= true;
write('Please type the value of the money:');readln(money1);

呢個係我第1次整的,可以自己改善程式的不足之處

2008-10-17 22:22:13 補充:
Part 2:

writeln('Please choose the kind of the output money');
writeln('1: Hong Kong dollar 2: Australian dollar 3: British pound');
writeln('4: Canadian dollar 5: Deutsche Mark 6: Japanese yen 7: US dollar');
write('Type the kind of money here:');readln(country);

2008-10-17 22:22:47 補充:
Part 3:
If (country = 1) then begin output:=1; inputk :=' Hong Kong dollar(s)'; end
else if (country = 2) then begin output:=5.94; outputk :=' Australian dollar(s)'; end
else if (country = 3) then begin output:=12.04; outputk :=' British pound(s)'; end

2008-10-17 22:23:17 補充:
Part4:
else if (country = 4) then begin output:=5.55; outputk :=' Canadian dollar(s)'; endelse if (country = 5) then begin output:=4.974; outputk :=' Deusche Mark(s)'; end
else if (country = 6) then begin output:=0.0768; outputk :=' Japanese yen(s)'; end

2008-10-17 22:23:26 補充:
Part5:
else if (country = 7) then begin output:=7.76; outputk :=' US dollar(s)'; end
else error:= true;
If (error = true) then begin writeln('invalid input'); readln; end
else

2008-10-17 22:23:31 補充:
Part6:
begin
money2 := money1*input/output ;
writeln(money1:16:5,inputk,'=',money2:16:5,outputk);
readln;
end;
end.

2008-10-20 19:07:02 補充:
新版內容已經email send 比你,請檢查email...
今次用左case...of


收錄日期: 2021-04-18 15:38:22
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20081017000051KK01203

檢視 Wayback Machine 備份