Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function TakeInt(Min,Max: Integer): Integer;
- var
- IsCorrect: Boolean;
- Number: Integer;
- begin
- Number := 0;
- repeat
- IsCorrect := True;
- try
- Readln(Number);
- except
- Writeln('Incorrect input!!!');
- IsCorrect := False;
- end;
- if (IsCorrect and (Number < Min) or (Number > Max)) then
- begin
- Writeln('Incorrect input!!!');
- IsCorrect := False;
- end;
- until IsCorrect;
- TakeInt := Number;
- end;
- static int takeInt(int min,int max) {
- int number = 0;
- boolean isIncorrect;
- do {
- isIncorrect = false;
- try {
- number = Integer.parseInt(scan.nextLine());
- } catch (NumberFormatException e) {
- System.out.println("Incorrect input!!!");
- isIncorrect = true;
- }
- if (!isIncorrect && (number < min || number > max)){
- System.out.println("Incorrect input!!!");
- isIncorrect = true;
- }
- }while (isIncorrect);
- return number;
- }
Add Comment
Please, Sign In to add comment