Vous êtes sur la page 1sur 5

program P1;

var
i,
j,
num,
e,
Prize_Money,
Largest_Points,
Total_Cash_Prize,
error
:integer;
var
District,
First_Place_Winner,
UserInput,
s
:string;
var STU_POINTS: array[1..10] of integer;
var STU_NAME: array[1..10] of string;

begin
{UserInput:='';}

i:=0;
j:=0;
e:=0;
error:=0;
Prize_Money:=0;
Total_Cash_Prize:=0;
Largest_Points:=-10; (*WELCOME -APP_NAME- FANCY ST
UFF?*)

(*------------------------------------------------------------------------------
-----------------------------------------------------*)
{District Input}
write('Enter your District Name: ');
readln(District);
(*------------------------------------------------------------------------------
-----------------------------------------------------*)

(*******************************************************************************
*****************************************************)
{Using this iterator to set the values into the
arrays: stu_points & stu_name}
for i:= 1 to 10 do
begin
writeln();
write('Enter Student Name: ');
readln(s);
STU_NAME[i]:=s;
repeat
write('Enter Student Point: ');
readln(UserInput);
val(UserInput,num,error);
until error=0;
STU_POINTS[i]:=num;
writeln();
end;(*End of For Loop*)
(*******************************************************************************
*****************************************************)

{ For
ur knowledge, you can delete it
and
or watch the video in the link.
*VALIDATING TH
E NUMERICAL INPUT USING VAL FUNCTION*
https://www.youtu
be.com/watch?v=HJSfbZXX2Ro
The Val(string,integ
er,integer) method takes
in those data types
and checks the userinput
in order to determin
e if it's a number or
string, if it happen
s to be a string then
the error integer wo
uld be made 1(and throw an error
which in this case i
s "Enter Student Point"). If it is
the UserInput is a n
umber then error variable is made
0. The num integer i
s where the
integer(Passed in by
UserInput)
gets stored and can
be further manipulated
as the programmer se
es fit.
}
(*******************************************************************************
*****************************************************)
{using this iterator to access vales from the arra
ys: stu_points & stu_name.}
for j:= 1 to 10 do
begin
if(STU_POINTS[j] > Largest_Points) then
begin
Largest_Points := STU_POINTS[j];
First_Place_Winner:=STU_NAME[j];
end;
end; (*End of For Loop*)
(*******************************************************************************
*****************************************************)

(*------------------------------------------------------------------------------
-----------------------------------------------------*)
{This Section prints the
first place winner}
writeln();
writeln();
writeln(' ','*********************************************');
writeln();
writeln(' ','*',' ','First Place Winner Goes To',' ','*
');
writeln();
writeln(' ','*',' ',First_Place_Winner,' from the ', District,'
District ','*');
writeln();
writeln(' ','*********************************************');
writeln();
writeln();
(*------------------------------------------------------------------------------
-----------------------------------------------------*)

(*------------------------------------------------------------------------------
-----------------------------------------------------*)
{This prints the heading
section of the table}
writeln('---------------------------------------------------------------')
;
writeln('*',' ', 'PRIZE MONEY',' ','DISTRICT','
','NAME');
writeln('---------------------------------------------------------------')
;
(*------------------------------------------------------------------------------
-----------------------------------------------------*)

(*******************************************************************************
*****************************************************)
(*Using this iterator in print
ing the Student Price Table*)
for e:= 1 to 10 do
begin
if(STU_POINTS[e] >= 75) then
Prize_Money := STU_POINTS[e]*100;
if(STU_POINTS[e]>=60) and (STU_POINTS[e]<=74) then
Prize_Money := STU_POINTS[e]*75;
if(STU_POINTS[e]<60) then
Prize_Money := STU_POINTS[e]*50;

writeln();
writeln('*',' ','$',Prize_Money,' ',District,'
',STU_NAME[e],' ');
writeln();
writeln('---------------------------------------------------------------'
);
Total_Cash_Prize:=Total_Cash_Prize + Prize_Money;
end; (*End of For Loop*)
(*******************************************************************************
*****************************************************)

(*------------------------------------------------------------------------------
-----------------------------------------------------*)
{Using this section in printing the tota
l funds given to the respective district}
writeln();
writeln();
writeln(' ','*********************************************');
writeln();
writeln(' ','*',' ','TOTAL FUNDS GIVEN TO ',District,' ','*
');
writeln();
writeln(' ','*',' ','$',Total_Cash_Prize ,'
','*');
writeln();
writeln(' ','*********************************************');
writeln();
writeln('<PRESS ENTER TO QUIT>');
readln();
(*------------------------------------------------------------------------------
-----------------------------------------------------*)

end. { End of Main }

Vous aimerez peut-être aussi