Bounded List Help!

I need help in writing a program which has the following operations in it

:- Add
Terminate
Search
IsFull
IsEmpty
Initialise
Deletebyvalue
Deletebyposition
Amend

I need to put these operations into a separate library program and have a driver program to call the operations to run/test them, also there has to be a menu so a user can select the operations. Can anyone help me??
Please help me if anyone can, thanx

Comments

  • I have attempted a program for the library program, here gos

    PROGRAM Menu (Input,Output);

    CONST max = 10;

    TYPE listtype = RECORD
    list : array [1 .. max] of integer;
    size : integer;
    END;
    itemtype = integer;

    VAR Bl : listtype;


    PROCEDURE add (VAR Bl:listtype;
    newitem:itemtype);

    BEGIN
    Bl.size := Bl.size + 1;
    Bl.list[Bl.size] := newitem;
    END;


    PROCEDURE Terminate (VAR Size : integer);

    BEGIN
    Size := 0;
    END;

    PROCEDURE Search (VAR Bl:listtype);

    BEGIN
    REPEAT
    Count := Size;
    IF Target : Numrecs [Count] THEN
    Found := True
    END;
    END;

    PROCEDURE IsFull (VAR Bl:listtype ; newitem : itemtype);

    BEGIN
    IF Bl.size = max THEN
    writeln ('Sorry the array is full!!')
    ELSE
    Bl.size := Bl.size + 1;
    Bl.list[Bl.size] := newitem;
    END;

    PROCEDURE IsEmpty (VAR Size : integer ; list : array);

    BEGIN
    Empty := False;
    IF Size = 0 THEN
    writeln ('the array is empty');
    END;

    PROCEDURE Deletebyvalue (VAR List : array ; Value : integer);

    BEGIN
    REPEAT
    IF Array[item] = value THEN
    FOR Array[item] TO Arraysize DO
    item := item -1
    Arraysize := Arraysize -1
    END

    PROCEDURE Deleteatposition (VAR pos : integer ; List : Array);

    BEGIN
    WHILE pos > 1 AND < Arraysize DO
    FOR pos TO Arraysize
    Array[Count] : =Array[Count -1]
    Arraysize := Arraysize -1
    END;

    PROCEDURE Amend (VAR Value : integer ; Newvalue : Integer);

    BEGIN
    Value := NewValue;
    END;


    {MAIN PROG}
    BEGIN
    add (Bl,newitem);
    Terminate (Size);
    Search;
    IsFull;
    Initialise;
    Deletebyvalue;
    Deleteatposition;
    Amend;
    END;



    This is what i have done so far, I wasnt to sure how to create a menu, anyone got any ideas??? This program doesnt work, apart from Add,Terminate and IsFull these procedures work, butr thats about it, Can anyone help me finish this program???? Plz?? Thanx

  • A very basic menu isn't hard to code. Here is one to get you started.

    [code]
    var
    choice:integer;
    repeat
    clrscr;
    writeln('1. Do first thing');
    writeln('2. Do second thing');
    writeln('3. quit');
    write('Make your choice: '); readln(choice);
    case choice of
    1: writeln('Call to DoFirstThing');
    2: writeln('Call to DoSecondThing');
    end;
    until choice=3;
    [/code]

    This menu will work, but isn't very useful. You'll have to make it more useful yourself, by changing the writeln's in the case-of statement to calls to real routines; and changing the descriptions of the other writeln's accordingly.
  • Bounded List? Looks awful familar to an ADS assessment, I hope you aren't trying to cheat. If this is your cause then you will be thrown out of college, quite promptly. I will be notifing Jane Zeland of this and i expect an apology. See me at my office chris, we need to chat.

    Denuta Stephens

    : I need help in writing a program which has the following operations in it
    :
    : :- Add
    : Terminate
    : Search
    : IsFull
    : IsEmpty
    : Initialise
    : Deletebyvalue
    : Deletebyposition
    : Amend
    :
    : I need to put these operations into a separate library program and have a driver program to call the operations to run/test them, also there has to be a menu so a user can select the operations. Can anyone help me??
    : Please help me if anyone can, thanx
    :

  • I posted this msg, to see if anyone would help me, not do the actual work, because I do not have a clear idea of wot im doin.
    Thanks very much danuta for accusing me of cheating!!!!
    U dont think I would take someone elses work of the web and use it for my-self????
    How dare u accuse me of cheating!!
  • Well its a pitty u cant spell the name properly m8!!
    Nice try tho u almost had me there!
Sign In or Register to comment.

Howdy, Stranger!

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

Categories