Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Lab1Challenge1;
- {$APPTYPE CONSOLE}
- {$R *.res}
- uses
- System.SysUtils;
- Var
- IsCorrect: Boolean;
- Rooms, Mans, Womans, MansRooms, WomansRooms: Integer;
- Begin
- Rooms := 0;
- Mans := 0;
- Womans := 0;
- MansRooms := 0;
- WomansRooms := 0;
- IsCorrect := False;
- Repeat
- Try
- Write('Rooms count (cannot be lower than 1): ');
- Readln(Rooms);
- If (Rooms >= 1) Then Begin
- IsCorrect := True;
- End Else Begin
- Writeln('Number must be not lower than 1!');
- End;
- Except
- Writeln('Enter number, not string or anything else!');
- End;
- Until IsCorrect;
- IsCorrect := False;
- Repeat
- Try
- Write('Mans count (cannot be lower than 0): ');
- Readln(Mans);
- If (Mans >= 0) Then Begin
- IsCorrect := True;
- End Else Begin
- Writeln('Number must be not lower than 0!');
- End;
- Except
- Writeln('Enter number, not string or anything else!');
- End;
- Until IsCorrect;
- IsCorrect := False;
- Repeat
- Try
- Write('Womans count (cannot be lower than 0): ');
- Readln(Womans);
- If (Womans >= 0) Then Begin
- IsCorrect := True;
- End Else Begin
- Writeln('Number must be not lower than 0!');
- End;
- Except
- Writeln('Enter number, not string or anything else!');
- End;
- Until IsCorrect;
- MansRooms := Mans Div 4;
- WomansRooms := Womans Div 4;
- If Not(MansRooms * 4 = Mans) Then
- MansRooms := MansRooms + 1;
- If Not(WomansRooms * 4 = Womans) Then
- WomansRooms := WomansRooms + 1;
- If (MansRooms + WomansRooms <= Rooms) Then Begin
- Writeln('Enough');
- End Else Begin
- Writeln('Not enough');
- End;
- Writeln('Press [ENTER] to close program...');
- Readln;
- End.
Advertisement
Add Comment
Please, Sign In to add comment