Не могу выйти из цикла - PullRequest
0 голосов
/ 29 марта 2019

Я не могу прочитать, чтобы изменить условие

program CFS;
    {Defining Constants}
    const
    {Pay Rates}
    ManagerBasic       = 8000;
    AssistManagerBasic = 7000;
    SupervisorBasic    = 5000;
    SalesStaffBasic    = 3000;

    {Allowances}
    DailyAllowance         = 0.11;
    TravelAllowance        = 0.06;
    EntertainmentAllowance = 0.035;
    CommissionRate         = 0.03;

    {Deductions}
    SocialSecurity  = 0.06;
    EnvironmentLevy = 0.01;
    Insurance       = 0.02;

    {creating and initialising variables where necessary}
    var
    Name       : string;
    //i          : integer = 0;
    StaffType  : string;
    TotalSales : real = 0.0;
    CommissionEarned : real = 0.0;
    MajorLoop : integer = 1;

  begin


    {this is just the psueudocode comments for the real program}

    writeln('The Caribbean Fashion Store');
    writeln('Electronic Communication Calculator Version 1.0.1');
    writeln('Build No. 001');
    writeln('Sands, Sheba');

    {We will use a while loop as a means of making the program start and stop at the user s will. First we ask for a choice:'}

    writeln();

    writeln('To process an employee, type 1 and press Enter, otherwise type 0 and press Enter'); 


    while (MajorLoop = 0) do
    begin

       writeln('To process another employee, type 1 and press Enter, otherwise type 0 and press Enter');



   end;

    writeln(ManagerBasic/DailyAllowance);

    {read is placed to stop the program}
    readln();


end.

1 Ответ

0 голосов
/ 23 апреля 2019

В разделе var вы инициализируете MajorLoop значением 1, чтобы цикл никогда не запускался.Измените while на что-то вроде

    while(MajorLoop = 1) do
    begin
      writeln('To process another employee, type 1 and press Enter, otherwise type 0 and press Enter');
      readln(MajorLoop);
    end;

Таким образом, если пользователь вводит 0, цикл заканчивается (я полагаю, это то, что вы хотите сделать).

...