Advertisement
Paarzivall

Untitled

Mar 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. package zajęcia3;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class wyjatek_cw {
  6.  
  7.     public static void main(String[] args) throws NieLiczba {
  8.         Scanner sc = new Scanner(System.in);
  9.         System.out.println("Podaj liczbę: ");
  10.         double input = 0;
  11.         while(true) {
  12.             try {
  13.                 input = sc.nextDouble();
  14.                 break;
  15.             }
  16.             catch(NieLiczba e) {
  17.                 System.out.println(e.getMessage());
  18.                 continue;
  19.             }
  20.         }
  21.     }
  22. }
  23.  
  24. class NieLiczba extends Exception{
  25.     public NieLiczba() {
  26.         System.out.println("Podaj liczbę!!!");;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement