標題:

Pascal 一問-----write program(20點)

發問:

Write a program to follow the grading table below to output final grade of a student.Mark----------------------Grade100-90----------------------A89-80-----------------------B79-70-----------------------C69-60---------------------- D59-50----------------------... 顯示更多 Write a program to follow the grading table below to output final grade of a student. Mark----------------------Grade 100-90----------------------A 89-80-----------------------B 79-70-----------------------C 69-60---------------------- D 59-50---------------------- E 49-30-----------------------F 29-0------------------------U Sample: (1) Enter mark: 65 Your grade is D. (2) Enter mark: 110 Please enter mark between 0-100 (3) Enter mark: -5 Please enter mark between 0-100 (4) Enter mark:100 Your grade is A. 更新: 唔好打中文 plz~~~~~~~~~~~~~~~ 更新 2: 點解run 唔到

aa.jpg

 

此文章來自奇摩知識+如有不便請留言告知

最佳解答:

program mark_report; Var mark: integer; BEGIN write ('Enter mark'); readln(mark); while not ((mark>=0) and not (mark<=100)) do begin repeat writeln ('Enter mark: '); readln(mark) until (mark>=0) and (mark<=100) end; write('Your grade is '); if (mark>=90) and (mark<=100) then writeln('A'); if (mark>=80) and (mark<=89) then writeln('B'); if (mark>=70) and (mark<=79) then writeln('C'); if (mark>=60) and (mark<=69) then writeln('D'); if (mark>=50) and (mark<=59) then writeln('E'); if (mark>=30) and (mark<=49) then writeln('F'); if (mark>=0) and (mark<=29) then writeln('U'); END.

其他解答:

Actually,we should use repeat loop and if..then... to deal it. here i tell you how to do it , after this ,there is finished work at last paragraph (1) <---it is variable Enter mark: 65 Your grade is D. (2) <---it is variable Enter mark: 110 Please enter mark between 0-100 Owing to varible value , so we need to make this: var i:integer; begin .... i:=0 ------at first assume it is 0 repeat -----it is a repeat loop because i assume you are making lots of marks i:= i 1 ------then add 1 to it,(i),since it is the second one and so on... writeln(i) -----it is because we have to show it out here i assume the values of mark is not suitable,so i will use if...then..loop : if mark<0 then writeln('Please enter mark between 0-100'); if mark>100 then writeln('Plese enter mark between 0-100'); next, again i used if..then.. loop : if (mark>=0) and (mark<=100) then--here >= it means larger than or equal to write('Your grade is '); and <= it means smaller than or equal to if (mark>=90) and (mark<=100) then writeln('A'); if (mark>=80) and (mark<=89) then writeln('B'); if (mark>=70) and (mark<=79) then writeln('C'); if (mark>=60) and (mark<=69) then writeln('D'); if (mark>=50) and (mark<=59) then writeln('E'); if (mark>=30) and (mark<=49) then writeln('F'); if (mark>=0) and (mark<=29) then writeln('U'); next, i put writeln; to skip a line writeln; writeln; at last ,i did it as 'until ..' until (mark>=0) and (mark<=0); end; 2008-09-27 15:25:32 補充: here it is finished work, program mark_report_repeat; uses crt; var mark,i:integer; begin clrscr; begin i:=0; repeat i:=i+1; writeln(i); write('Enter mark:'); readln(mark); 2008-09-27 15:26:03 補充: if mark<0 then writeln('Please enter mark between 0-100'); if mark>100 then writeln('Plese enter mark between 0-100'); if (mark>=0) and (mark<=100) then write('Your grade is '); 2008-09-27 15:26:14 補充: if (mark>=90) and (mark<=100) then writeln('A'); if (mark>=80) and (mark<=89) then writeln('B'); if (mark>=70) and (mark<=79) then writeln('C'); if (mark>=60) and (mark<=69) then writeln('D'); 2008-09-27 15:26:18 補充: if (mark>=50) and (mark<=59) then writeln('E'); if (mark>=30) and (mark<=49) then writeln('F'); if (mark>=0) and (mark<=29) then writeln('U'); writeln; writeln; until (mark>=0) and (mark<=0); end; End. 2008-09-27 15:27:13 補充: Because the restriction of word size , i am sorry to cut it parts 2008-09-27 15:32:13 補充: i am pleasure to answer your question , and if you had any question about it , you could ask me,^^|||||program 名; BEGIN write (''Enter mark''); readln(mak); while not ((mak>=0) and not (mak<=100)) do begin repeat writeln ('' Please enter mark between 0-100 "); readln(mak) until (mak>=0) and (mak<=100) end; 之後個d純純係 A. if (>=lower mak) and (<=higher mak) then 1 條件1 WRTIELN (...U) B. else if .......... and ........... then 2 條件2 ........(...F) 之後C配3到G配7都係如此. END.
arrow
arrow

    ohe09nz81r 發表在 痞客邦 留言(0) 人氣()