0

I need to write a skeletn program for the assignment. It should have a menu system with at least 5 options. The menu keeps repeating after each procedure is called. When one of the procedures is called just return a message to the screen saying what this procedure will do: ie "this is task 1".

The menu opions are:
1     Enter a new stock item
2     Delete a stock item
3     Update  current item's details
4     Pint reports on stock status
5     Exit

My answer is:


program project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
        user_choice: integer;

begin
        writeln('Please enter an integer in the range 1...5');
        readln(user_choice);
        while not(user_choice in [1,2,3,4,5]) do
           begin
              write('Invalid entry.  Please re-enter .. ');
              readln (user_choice);
           end;


        readln;
end.

What are missing? What can I do to do show the above screen?

Cheers,

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by FlamingClaw
0

Example? :)

{
Question
The menu opions are:
1 Enter a new stock item
2 Delete a stock item
3 Update current item's details
4 Pint reports on stock status
5 Exit
}
Program Solution01;
Uses Crt;

Var User_Choice:Integer;

{the procedures}
Procedure NewStock;
  Begin
    WriteLn('1 pressed,entering a new stock item...');
    ReadLn;
  End;

Procedure DeleteStock;
  Begin
    WriteLn('2 pressed,deleting a stock item...');
    ReadLn;
  End;

Procedure UpdateItem;
  Begin
    WriteLn('3 pressed,updating item''s data...');
    ReadLn;
  End;

Procedure PrintReports;
  Begin
    WriteLn('4 pressed,printing reports...');
    ReadLn;
  End;

Procedure GetOutOfHere;
  Begin
    WriteLn('5 pressed,exiting...');
    ReadLn;
    Halt;{it is really stops the program}
  End;


Begin {main}
   User_Choice:=0;
   While User_Choice <> 5 Do Begin
    ClrScr;
    WriteLn('Please enter an integer in the range 1...5');
    WriteLn;
    WriteLn('  1 Enter a new stock item');
    WriteLn('  2 Delete a stock item');
    WriteLn('  3 Update current item''s details');
    WriteLn('  4 Pint reports on stock status');
    WriteLn('  5 Exit');
    WriteLn;
    {$I-}
    ReadLn(User_Choice); {catch the answer}
    {$I+}
    If IoResult<>0 Then begin
         WriteLn('Error.....');
         Readln;
         ReadLn;
         Halt;
    End;
    {call our above procedures}
    Case (User_Choice) Of
         1:NewStock;
         2:DeleteStock;
         3:UpdateItem;
         4:PrintReports;
         5:GetOutOfHere
    Else Begin
             WriteLn('Wrong Number..');
             WriteLn('Exiting...');
             Break;
         End;
    End;{case}
    End;

   ReadLn;
End.

{
-= Note By FlamingClaw =-

All programs created by me  are written and tested
in Dev Pascal and/or Turbo Pascal 7.0.Of course
working....

-= Created By FlamingClaw =-
-=2009.04.01=-
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.