Re: CAN ANY ONE RE-DO THIS TO MAKE IT MORE EASYER?Posted by webmaster Guido on March 30, 19103 at 21:47:26: In Reply to: Re: CAN ANY ONE RE-DO THIS TO MAKE IT MORE EASYER? posted by Kevin -=-Laaaaaaaaatttteeee on March 29, 19103 at 15:57:02:
: : : Can anyone re=do this without changing the basic layout? : : : procedure displayGrade(mark : integer); : : : var : : What do you mean by "redo this"? I think that this code can not be simplified, by leaving out whatever part you would break it. : : But there is one statement missing, you have to declare "Stop". Add this right before the "var" statement: : : const : Thank you But what else can you use instead of case mark of? or with the numbers can you change the format of them ? You can replace the "CASE" with a series of IF... THEN... ELSE... but personally, I think that "CASE" is a lot easier to read. procedure DisplayGrade(Mark : integer); begin if (Mark > -1) and (Mark < 50) then WriteLn('Fail') else if Mark < 65 then WriteLn('Pass') else if Mark < 80 then WriteLn('Credit') else if Mark < 101 then WriteLn('Honours') else WriteLn('invalid entry'); end; const Stop = -1; var Grade : integer; begin repeat Write('Enter Grade or mark (-1 to stop) >'); ReadLn(Grade); if Grade <> Stop then DisplayGrade(Grade); until Grade = stop end. |
|