Question:
pascal programming help?
Jayy Singh
2010-10-10 09:48:46 UTC
Create a menu system which will allow the user to:
Enter Data of 10 pupil ages
View all current Ages
Edit currently held data
Delete Individual records
Clear currently held Data
Four answers:
mystic smeg
2010-10-10 14:22:15 UTC
Hey Jayy,



All done, send me a mail as requested and I'll post you the code.



na



---- listing ----

program Demo2;



uses Crt;



var Ages: array[0..99] of integer; {define ages array}

Count: Integer; {used to count actual ages entered}

Done: boolean; {program done, true/false}



{ support functions and procedures }



function IntToStr(i: integer): string;

var res: string; {function result}

begin

{convert a string into an integer}

Str(i,res); {convert integer i into string res}

IntToStr:=res; {return function result}

end; {IntToStr}



function StrToInt(s: string): Integer;

var res,v,c: integer; {result, value, code}

begin

{convert an number into an integer}

res:=0; {default result}

if Length(s)>0 then {if length of s is greater than zero}

begin

Val(s,v,c); {convert string s into value v}

if c=0 then res:=v; {if success (code=0), then res=value v}

end; {if}

StrToInt:=res; {return function result}

end; {StrToInt}



function GetChoice(F,T: Char): integer;

var res: integer; {result}

Spk,Asc: integer; {spk=special key, asc=ascii key}

begin

{wait for, and return, a users 'key' choice}

res:=-1; {default result}

while (res=-1) do {loop while res=-1}

begin

Spk:=0; {default spk}

Asc:=Ord(UpCase(ReadKey)); {capture key}

if Asc=0 then {if asc=0}

begin

Spk:=1; {mark special key press,}

Asc:=Ord(UpCase(ReadKey)); {and then capture actual key}

end; {if}

if (Spk=0) and (Asc in [Ord(F)..Ord(T)]) then {if not spk, and asc in specified key range}

res:=Asc-Ord(F); {calculate result}

end; {while}

GetChoice:=res;

end; {GetChoice} {return function result}



{ main program functions and procedures }



procedure ClearAllData(Ask: boolean);

var i: integer; {i used for index in array}

begin

{Clear all data in the Ages array}

i:=1; {default i=1}

if Ask then {if ask user (confirm clear)}

begin

WriteLn; {new line}

Write('Are you sure you want to clear all data [1=Yes, 0=No]? '); {write some text}

i:=GetChoice('0','1'); {get the users choice}

end; {if}

if i=1 then {if i=1 then}

begin

for i:=Low(Ages) to High(Ages) do {loop from start to end of array}

Ages[i]:=0; {set Ages[i] = 0}

Count:=Low(Ages)-1; {finally, set count = low ages}

end; {if}

end; {ClearAllData}



procedure InputAges(Qty: integer);

var i: integer; {integer i, used for index}
anonymous
2010-10-10 16:59:02 UTC
The data you listed is going to be your menu. With each item you would have to write the program to do the functions required.



What you are asking is just the simple basics of Pascal, it does get more involved and technical later on. Practice different things when you have time and read a few articles about Pascal. Go on the Web and search for some source codes and play with them. Programming, no matter what language you use is not easy for quite a few months.
anonymous
2010-10-10 16:55:50 UTC
You write it, we'll help you fix the bugs.



ReadLn for input, WriteLn for output. You'll have to decide how you're holding data (variables [use an array], text file, database) before you can write editing, deleting and clearing (just delete all) code.
Question
2010-10-10 16:51:14 UTC
I'd love to do your homework for you, but its for you to do , not us!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...