redmanexe

Lab1Challenge1Delphi

Sep 12th, 2024 (edited)
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. program Lab1Challenge1;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. {$R *.res}
  6.  
  7. uses
  8. System.SysUtils;
  9.  
  10. Var
  11. IsCorrect: Boolean;
  12. Rooms, Mans, Womans, MansRooms, WomansRooms: Integer;
  13.  
  14. Begin
  15. Rooms := 0;
  16. Mans := 0;
  17. Womans := 0;
  18. MansRooms := 0;
  19. WomansRooms := 0;
  20. IsCorrect := False;
  21.  
  22. Repeat
  23. Try
  24. Write('Rooms count (cannot be lower than 1): ');
  25. Readln(Rooms);
  26. If (Rooms >= 1) Then Begin
  27. IsCorrect := True;
  28. End Else Begin
  29. Writeln('Number must be not lower than 1!');
  30. End;
  31. Except
  32. Writeln('Enter number, not string or anything else!');
  33. End;
  34. Until IsCorrect;
  35.  
  36. IsCorrect := False;
  37. Repeat
  38. Try
  39. Write('Mans count (cannot be lower than 0): ');
  40. Readln(Mans);
  41. If (Mans >= 0) Then Begin
  42. IsCorrect := True;
  43. End Else Begin
  44. Writeln('Number must be not lower than 0!');
  45. End;
  46. Except
  47. Writeln('Enter number, not string or anything else!');
  48. End;
  49. Until IsCorrect;
  50.  
  51. IsCorrect := False;
  52. Repeat
  53. Try
  54. Write('Womans count (cannot be lower than 0): ');
  55. Readln(Womans);
  56. If (Womans >= 0) Then Begin
  57. IsCorrect := True;
  58. End Else Begin
  59. Writeln('Number must be not lower than 0!');
  60. End;
  61. Except
  62. Writeln('Enter number, not string or anything else!');
  63. End;
  64. Until IsCorrect;
  65.  
  66. MansRooms := Mans Div 4;
  67. WomansRooms := Womans Div 4;
  68.  
  69. If Not(MansRooms * 4 = Mans) Then
  70. MansRooms := MansRooms + 1;
  71. If Not(WomansRooms * 4 = Womans) Then
  72. WomansRooms := WomansRooms + 1;
  73.  
  74. If (MansRooms + WomansRooms <= Rooms) Then Begin
  75. Writeln('Enough');
  76. End Else Begin
  77. Writeln('Not enough');
  78. End;
  79.  
  80. Writeln('Press [ENTER] to close program...');
  81. Readln;
  82. End.
Tags: delphi
Advertisement
Add Comment
Please, Sign In to add comment