I need to know how can I write it in pascal??? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

I need to know how can I write it in pascal???

Aggyness_90Aggyness_90 Posts: 5Member
1) Insert information
2)search by student number
3)display all information
4)delete by student number
5)Exit
please enter your choice
======================================

Comments

  • AtexAtex Posts: 268Member
    : 1) Insert information
    : 2)search by student number
    : 3)display all information
    : 4)delete by student number
    : 5)Exit
    : please enter your choice
    : ======================================
  • Aggyness_90Aggyness_90 Posts: 5Member
    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???
  • AtexAtex Posts: 268Member

    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: [b]names, fields, terms: array[1..100] of String[red][35][/red];[/b]
Sign In or Register to comment.