Advertisement
nikitaxe132

Untitled

Oct 29th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. static int numb() {
  2.         boolean invalidinput = false;
  3.         int n = 0;
  4.         do {
  5.             boolean iscorrect = false;
  6.             try {
  7.                 BufferedReader input = new BufferedReader(new FileReader("D:\\input.txt"));
  8.                 String text = input.readLine();
  9.                 do {
  10.                     System.out.print("Enter the number of sequence members ");
  11.                     n = Integer.parseInt(text);
  12.                     System.out.println(n);
  13.                     iscorrect = enter(n, 10, 1);
  14.                 } while (iscorrect);
  15.             } catch (FileNotFoundException e) {
  16.                 System.out.println("A file with the same name was not found");
  17.                 invalidinput = true;
  18.             } catch (IOException e) {
  19.                 System.out.println("This file cannot be opened");
  20.                 invalidinput = true;
  21.             } catch (NumberFormatException e) {
  22.                 System.out.println("Error! File contains invalid data");
  23.                 invalidinput = true;
  24.             }
  25.         } while (invalidinput);
  26.         return n;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement