Advertisement
Ewerlost

Lab1_Delphi

Sep 23rd, 2023 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.09 KB | None | 0 0
  1. Program Lab1;
  2. Uses
  3.   System.SysUtils;
  4.  
  5. Var
  6.     Gen : Char;
  7.     Age, ReAge : Integer;
  8.     IsCorrect : Boolean;
  9. Begin
  10.     Writeln( 'This program will find the recommended age for marriage' );
  11.     Writeln( 'Man or Woman ? ENTER M if you are a man or W if you are a woman and your age.' );
  12.     Repeat
  13.         IsCorrect := True;
  14.         Try
  15.             Readln(Gen, Age);
  16.             If ( Gen <> 'M' ) And ( Gen <> 'W' ) Then
  17.             Begin
  18.                 Writeln( 'Enter existing gender' );
  19.                 IsCorrect := False;
  20.             End;
  21.  
  22.             If ( Age < 16 ) Or ( Age > 100 ) Then
  23.             Begin
  24.                 Writeln( 'Enter acceptable age(16-100)' );
  25.                 IsCorrect := False;
  26.             End;
  27.         Except
  28.             Writeln( 'Data entered incorrectly, please re-enter' );
  29.             IsCorrect := False;
  30.         End;
  31.     Until (IsCorrect);
  32.         If ( Gen = 'M' ) Then
  33.             ReAge := Age Div 2 + 7
  34.         Else
  35.             ReAGe := Age * 2 - 14;
  36.         Writeln( 'Recommended age of a candidate for marriage : ', ReAge );
  37.         Readln;
  38. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement