中三電腦程式問題

2009-04-14 12:03 am
指出以下程式的錯處:
1. 找出由寶林至北角港鐵單程票應繳付的款項:

var type; fare;

type = prompt( );

if(type = 成人){

fare = =9.5;

} else {

fare = 4.8;

}

alert(fare);

2.找出會考等級(A,B,C,D,E,F,U)對應評語:

var grade;

grade = prompt( );

if(grade = A){

comment = 'Distinction';

}

if(grade = = 'B' && grade = = 'C'){

comment = = 'Credit';

}

if(grade > 'D' and < 'F') {

comment= 'Pass';

}else{

comment = 'Fail';

}

alert ('comment');

回答 (2)

2009-04-18 12:43 am
✔ 最佳答案
第一題錯處如下, 左邊係行號, 右邊係改正:

1: var type, fare;
3: if (type == '成人') {
4: == -> =


第二題:
3: if (grade == 'A') {
7: comment = 'Credit';
9: if(grade >= 'D' and grade < 'F') {
14: alert(comment);
2009-04-18 6:40 am
第一題第4唔係好明??

== -> =係咩???改係邊??


收錄日期: 2021-04-13 16:33:51
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090413000051KK01223

檢視 Wayback Machine 備份