Pascal Help NEEDED!

February 28, 2010 at 14:21:47
Specs: Windows XP
I can not get this program to run. i need it
running asap. i tried everything and then some
to get it running. plz help!

program BookMonitoringSystem;
uses wincrt;
var i,s,cost,fine:integer;
var
student,book,minimal,moderate,severe,missin
g:string[10];

Begin

writeln ('welcome to the Learning Tree Book
Monitoring System');

for i:=1 to 20 do

writeln (' Please enter the first students
name');

read (student);
Begin
for s:=1 to 5 do

writeln ('Please enter the condition of the first
book');

read (book);

writeln ('Please enter the cost of the first
book');

read (cost);

begin

if (book)= ('minimal')then

fine:=(cost)*0.30

else

if (book)= ('moderate')then

fine := (cost)*0.65
end;

begin
if (book) = ('severe')then

fine := (cost)*1.2
end;

begin
if (book) = ('missing')then

fine := (cost)*1.2
end;

writeln ('Students name') (student);

writeln ('Book Conditon') (book);

writeln ('Book Cost') (cost);

writeln ('Fine incurred') (fine);

end;
end;
end.


See More: Pascal Help NEEDED!

Report •

#1
February 28, 2010 at 16:40:50
var.s fine (at least, but also cost) should be type long (or whatever pascal uses, float, double, etc), since you are multiplying by non-integer values (.30, 1.2 etc).
also, you really need a case-structure here (i am sure pascal implements it), IF/THENs can be pushed into service and made to work, but they are a terror to debug and just look gnarley in general.
you have no "next s" or "next i" terminating the loops.
it is very bad practice to not allow an "escape" from the program, always, but especially when the loops are long (20 times 5 equals 100 repetitions. do YOU want to sit there hitting <RETURN> 100 times? not me)
I would suggest using a "while" or "until" loop instead of for-loops.
This looks like a "homework problem", but i'll offer this much help anyway, and final suggestion to use either pseudocode or flowchart or both to help define (& REfine) your code-structure.

Report •

#2
March 1, 2010 at 05:41:01
thank you nbrane. it was a homework question but i was allowed
to get help.

Report •
Related Solutions


Ask Question