Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
I need to know how can I write it in pascal??? Posted by Aggyness_90 on 18 Nov 2009 at 11:52 AM
1) Insert information
2)search by student number
3)display all information
4)delete by student number
5)Exit
please enter your choice
======================================…
write a program that has the above menu & Contains(max) 100 students with the information(name/students number(code)/field/term)....store them & can do the above performance(in the above menu)
note: without using 'record'
Report
Re: I need to know how can I write it in pascal??? Posted by Atex on 20 Nov 2009 at 8:49 AM
: 1) Insert information
: 2)search by student number
: 3)display all information
: 4)delete by student number
: 5)Exit
: please enter your choice
: ======================================…
: write a program that has the above menu & Contains(max) 100 students
: with the information(name/students number(code)/field/term)....store
: them & can do the above performance(in the above menu)
: note: without using 'record'
:

That looks like a homework assignment to me, so no code this time... start writing yourself and ask for help with code examples if you get stuck. Hint: use arrays if you cannot use records.
Report
Re: I need to know how can I write it in pascal??? Posted by Aggyness_90 on 22 Nov 2009 at 6:51 AM
program StudentManagement;
{
Author:
This program adds, deletes, searches students in an array.
}

uses
crt;

var
names, fields, terms: array[1..100] of String;
codes: array[1..100] of Integer;
n: Integer;

procedure display_information(i: Integer);
begin
Writeln(codes[i]);
Writeln(names[i]);
Writeln(fields[i]);
Writeln(terms[i]);
end;

procedure SetStudentInfo(nam: String; code: Integer; field: String; term: String; i: Integer);
begin
names[i] := nam;
codes[i] := code;
fields[i] := field;
terms[i] := term;
end;


procedure InsertInformation;
var
nam, field, term: String;
code: Integer;

begin
{Get details}
Write('Enter the name of the student: ');
Readln(nam);
Writeln;

Write('Enter the code: ');
Readln(code);
Writeln;

Write('Enter the field of the field: ');
Readln(field);
Writeln;

Write('Enter the term: ');
Readln(term);
Writeln;

{Set info for a new student with these details}
SetStudentInfo(nam, code, field, term, n+1);

n := n + 1; {Increment number of students by 1}
Writeln('The student has been added.');
end;

procedure SearchStudent;
var
code, i: Integer;

begin
Writeln('Enter the code of the student to search: ');
Readln(code);

for i := 1 to n do
begin
if codes[i] = code then
begin
Writeln('The student has been found.');
Writeln('Details are: ');
display_information(i);
Exit;
end;
end;

Writeln('The student with code ', code, ' is not present.');
end;

procedure DeleteStudent;
var
code, i, j: Integer;

begin
Write('Enter the code of the student to delete: ');
Readln(code);

for i := 1 to n do
begin
if codes[i] = code then
begin
{
Student has been found
The student at index i has to be deleted.
Therefore shift all students from index i to last by one step back
}

for j := i+1 to n do
begin
names[j-1] := names[j];
codes[j-1] := codes[j];
fields[j-1] := fields[j];
terms[j-1] := terms[j];
end;


{Decrement count of students by 1}
n := n - 1;
Writeln('The student with code ', code, ' has been deleted.');
Exit;
end;
end;

Writeln('The student with code ', code, ' is not present.');
end;


var
choice, i: Integer;
quit: Boolean;

begin
n := 0; {number of stuents}
quit := False;

while quit = false do
begin
Writeln('#####################################');
Writeln('Select an option from the following:');
Writeln('1) Insert information');
Writeln('2) Search and display all information by student number');
Writeln('3) Delete by student number');
Writeln('4)Exit');
Writeln('#####################################');

Readln(choice);
Case choice of
1: InsertInformation;
2: SearchStudent;
3: DeleteStudent;
4: quit := True;
else
Writeln('You made an invalid choice');


end;
end;
end.

well you know I've tried to do it....but I cannot run this in Borland Pascal!!!!what should I do???
Report
Re: I need to know how can I write it in pascal??? Posted by Atex on 22 Nov 2009 at 8:27 PM

You exceeded the maximum allowed data size in BP/TP (variables + constants), it must fit the data segment (65535 bytes), if you run it from FP it should work fine. To make it work under BP change the string variables to a reasonable length like 35 characters: names, fields, terms: array[1..100] of String[35];



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.